memory leaks with ctypes LoadLibrary ?

chris cgrebeld at gmail.com
Tue Mar 1 11:30:34 EST 2005


What is the proper way to use ctypes to access an exported Function in
a dll file on windows?  I must be missing something because I get
memory leaks when I  use it:

import ctypes
import gc

gc.enable()
gc.set_debug(gc.DEBUG_LEAK)
lib = ctypes.windll.LoadLibrary("H:\lib\mylib.dll")
fn = lib.myfn
fn("test")
del fn
del lib
gc.collect()
gc: uncollectable <WinDLL instance at 015DFFA8>
gc: uncollectable <dict 015D9420>
gc: uncollectable <_StdcallFuncPtr 015DAE48>
gc: uncollectable <list 014E2030>
4

What am I doing wrong?




More information about the Python-list mailing list