In Java the &quot;destroy&quot; method is called finally and is present on vtkObjectBase (it calls the&nbsp; VTK Delete method). If you look at the garbage collector the java vtk objects are deleted (you say no but what have you done to know there is java objets that are not destroyed ?) and there is no memory leak in the java side, so theorically there is no memory leak at all if the JNI code is nice coded.<br>
<div class="gmail_quote">
<br>But I have a memory leak in a complexe program that do the same thing than you but in another program that require a lot of construction/destruction of objets there is no memory leak so I think it&#39;s possible there is a leak in the C++ parts on some classes (in my case I think vtkExtractSelectedFrustum does a leak).<br>

<br>You have to take care about two points :<br><br>The java garbage collector works with allocation in java. If you construct a vtkPolyData with 1 million of triangle, in the java side the object will take a little of memory (less than 1Ko) but in the native parrt it will take a lot of Mo. So the garbage will not destroy him because it&#39;s unecessary (it not sees the native allocation parts). So to force the destruction you have to call it explicitely : System.gc(); and the objet will be destroyed.<br>

<br>The vtkGarbageCollector does not destroy the weak reference of the vtk objects even if they are destroyed (the weak reference becomes null but is not destroyed). This is a memory leak but a very little memory leak that does not make problem (a weak reference take a very little size of memory).<br>

<br>In conclusion, on my tests it&#39;s seems that the java side is clean, that in certain case there is no memory leak so the JNI seems to not have memory leak (because if the memory leak is on the JNI code it have to be memory leak always) and the fault is surely in the C++ parts but it&#39;s not sure at all.<br>

<br><div class="gmail_quote">2008/6/14 Oscar Javier Chavarro Garcia &lt;<a href="mailto:oj.chavarro184@uniandes.edu.co" target="_blank">oj.chavarro184@uniandes.edu.co</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">
Hello all.<br><br>I&#39;m just a newbie, sorry if this question is too obvious or in the wrong list.<br><br>I&#39;m using the marching cubes filter in Java, and the program works fine when testing small volumes. Big volumes exceeds my RAM capacity (4GB), so I made a cycle to break my volume in parts and call several times the marching cubes algorithm to obtain partial polygon meshes which I glue together later on. For the first few chunks in this process goes fine, until the program dies because of insufficient memory.<br>

<br>I have noticed that objects are not getting garbage-collected, no matter how I tried to decrease their reference count. I&#39;ve called vtkGarbageCollector.Collect, vtkObjectBase.UnRegister, vtkObject.FastDelete in several forms with no luck. Java wrapped VTK seems to have the vtkObjectBase.Delete method missing.&nbsp; How do I free RAM from unused objects?<br>

<font color="#888888"><br>-Oscar Chavarro-<br><br>
</font><br></div></div>_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><font color="#888888">Julian Ibarz
</font></div><br><br clear="all"><br>-- <br>Julian Ibarz