This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes leaks memory
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: theller Nosy List: theller
Priority: normal Keywords: patch

Created on 2007-01-24 21:12 by theller, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ctypes.patch theller, 2007-01-24 21:12
Messages (2)
msg51795 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2007-01-24 21:12
This program leaks memory, because a string is allocated with the win32 call SysAllocString(), but SysFreeString() is never called.

"""
from ctypes import oledll, _SimpleCData

class BSTR(_SimpleCData):
    _type_ = "X"

func = oledll.oleaut32.SysStringLen
func.argtypes = (BSTR,)

while 1:
    func("abcdefghijk")

"""

The attached patch fixes this.

(The BSTR data type is not exposed by ctypes or ctypes.wintypes, because it is only used in connection with Windows COM objects.)

The patch should be applied to release25-maint and trunk.
msg51796 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2007-01-25 19:24
Fixed in r53556, r53557 (trunk) and r53558 (release25-maint).
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44504
2007-01-24 21:12:11thellercreate