[vtkusers] How to properly manage memory using Python and VTK

mwormser max.wormser at gmx.de
Mon Apr 4 05:59:07 EDT 2016


Hi, I am facing a problem with my first VTK program that I wrote in Python
2.7. I only started using VTK a few weeks ago, so please bear with my
beginner's mistakes.

What my program does is it creates 12 lines that form a kind of cubic grid.
These lines get faces using vtkTubeFilter, appended into one object with
vtkAppendPolyData and cut to right size using vtkClipClosedSurface. Then I
duplicate the resulting cell using vtkTransform (e.g. 5x5x5 cells), append
them again (and cut and recenter them again in certain cases). The result is
rendered and saved as .stl.

My program manages up to 9x9x9 cells, but starting with 10x10x10 it gives an
error like "Unable to allocate 30106875 elements of size 8 byte." The
machine I am working on has 12 GB RAM. I realize that my structure is really
big (resulting stl way over 200MB), but I want to get to at least 10x10x15
cells.

Is there a way to save memory in my program? I have no clue about memory
management. I read about SmartPointers, but can't seem to figure out how to
use them in Python (I don't know C++). I tried using SetReleaseDataFlag(1)
on the Filters after they were redundant, but that somehow deleted the
filter recursively.

Does anybody know a programming solution for this or do I have to use a
system with more RAM? Sorry for not posting a minimal example, but my
program is rather lengthy. I did post a small example to stackoverflow,
though
(http://stackoverflow.com/questions/36354985/memory-management-with-python-and-vtk)
which hasn't received any answers yet.

Thanks for any help in advance!



--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-properly-manage-memory-using-Python-and-VTK-tp5737509.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list