Re: memory leaks with ctypes LoadLibrary ?

2005-03-01 Thread Chris Grebeldinger
So, am I misinterpreting what gc.collect is printing, and there is
actually no memory leak?

Or if I'm not and there actually is a problem, Is there a better way to
use ctypes so that I don't have to modify the module?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: memory leaks with ctypes LoadLibrary ?

2005-03-01 Thread Thomas Heller
"chris" <[EMAIL PROTECTED]> writes:

> 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 
> gc: uncollectable 
> gc: uncollectable <_StdcallFuncPtr 015DAE48>
> gc: uncollectable 
> 4
>
> What am I doing wrong?

Nothing ;-) You could delete or comment out the __del__ method of class
CDLL, in the file ctypes/__init__.py.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: memory leaks with ctypes LoadLibrary ?

2005-03-01 Thread Thomas Heller
"chris" <[EMAIL PROTECTED]> writes:

> 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 
> gc: uncollectable 
> gc: uncollectable <_StdcallFuncPtr 015DAE48>
> gc: uncollectable 
> 4
>
> What am I doing wrong?

Nothing ;-) You could delete or comment out the __del__ method of class
CDLL, in the file ctypes/__init__.py.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


memory leaks with ctypes LoadLibrary ?

2005-03-01 Thread chris
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 
gc: uncollectable 
gc: uncollectable <_StdcallFuncPtr 015DAE48>
gc: uncollectable 
4

What am I doing wrong?

-- 
http://mail.python.org/mailman/listinfo/python-list