[vtkusers] VTK memory management

Thiago Franco Moraes tfmoraes at cti.gov.br
Thu Aug 30 07:55:39 EDT 2012


On Wed, Aug 29, 2012 at 5:38 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> In general python's memory management is fairly deterministic because
> it relies on reference counting (i.e. most objects are deleted as soon
> as they aren't needed anymore).  But if reference cycles are present,
> the behavior can become non-deterministic, because it depends on when
> the garbage collector is run.  You can always call gc.collect()
> yourself to force the garbage collection to occur at certain times in
> your program.
>
>  - David

Thanks David. If I call gc.collect() at the end of my pipeline, the
same happens, the memory measurement is very fluctuating.

> On Wed, Aug 29, 2012 at 2:03 PM, Thiago Franco Moraes
> <tfmoraes at cti.gov.br> wrote:
>> Hi,
>>
>> I'm doing some tests about memory management in VTK with Python. I
>> wrote this little python script [1]. It takes as parameter a filename
>> to a vtkPolydata saved in a xml file and do some processings in it. In
>> this script I'm taking care of freeing the memory used by each filter
>> and intermediate vtkPolydata. I'm using an tool called memory profiler
>> (very interesting by the way) [2] to measure the memory used along the
>> script execution. The problem is the memory measurement in the end of
>> script execution is somewhat strange, because the memory measurement
>> is very fluctuating, ranging from 170MB to 500MB. Is this expected?
>> I'm freeing memory from vtk objects in the right way? It's a problem
>> with Python?
>>
>> Thanks!
>>
>> [1] - http://pastebin.com/iYUK1jxk
>> [2] - https://github.com/fabianp/memory_profiler



More information about the vtkusers mailing list