[issue7959] ctypes memory leak

Thomas Heller report at bugs.python.org
Thu Feb 18 22:13:40 CET 2010


New submission from Thomas Heller <theller at ctypes.org>:

This little script 'ctypes-leak.py' leaks memory:

"""
import gc
from ctypes import *

PROTO = WINFUNCTYPE(None)

class Test(object):
    def func(self):
        pass

    def __init__(self):
        self.v = PROTO(self.func)


while 1:
    try:
        Test()
        gc.collect()
    except KeyboardInterrupt:
        print len([x for x in gc.get_objects()
                   if isinstance(x, Test)])
"""

The cause is that patch related to issue #2682; it leaks since rev. 62481 (in trunk) and rev. 62484 (in py3k).

I have not yet been able to find the cause of the leak.

----------
assignee: theller
components: ctypes
files: ctypes-leak.py
messages: 99527
nosy: theller
severity: normal
status: open
title: ctypes memory leak
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file16253/ctypes-leak.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7959>
_______________________________________


More information about the Python-bugs-list mailing list