[vtkusers] python interface to multithreader?
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Fri Mar 1 03:04:02 EST 2002
>>>>> "AG" == Alexandre Guimond <guimond at bwh.harvard.edu> writes:
AG> Also, I assumed that when I 'del SomeVtkObject' from python,
AG> the memory would be delete. That doesn't seem to be the case.
AG> For example, if I load an image with vtkImageReader, then
AG> Update, and then 'del reader', the python interpreter still
AG> uses the memory used to load the image. At least, that's what
AG> 'top' reports. Any clues on how to preperly destroy vtk
AG> objects in python and release the memory? Is there some weird
AG> garbage collection thing I should use?
When you del the object the memory may not be freed immediately.
However, I'm sure there arent bad leaks in Python. Reference counting
can have funny side effects. For instance if you catch an exception
the object will not be deleted until you raise another one. This is
because the exception handler somewhere in the sys module will still
have a reference to your object. Sometimes even with a trivial test
case the mem usage wont come down. Just try this with the following
code:
a = range(100000)
# memory usage goes up
del a
# comes down but not to the same usage with which it started.
However, if you repeat this often you wont see memory usage increasing
beyond the first instantiation of a. So, maybe measuring memory usage
with top is misleading.
I'm not aware of bugs in the vtk 3.2 Python wrappers that might cause
a leak. Others and I have been using the Python wrappers for quite a
while and memory usage has not posed a problem.
Also, Python 2.x has a garbage collection module. Look at the gc
module for details. Note that garbage collection is on by default.
prabhu
More information about the vtkusers
mailing list