<div dir="ltr">Hum, <div><br></div><div>Out of curiosity can you try using vtkPanel instead and calling its Java implementation of the delete() function and see if you can see it disappear or not within you tool (NetBean?)?</div><div><br></div><div>I'm wondering which piece keep a ref on it...</div><div><br></div><div>Seb</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 18, 2016 at 4:06 PM, Kenji Tsumura <span dir="ltr"><<a href="mailto:kenji.tsumura@neosoftmedical.com" target="_blank">kenji.tsumura@neosoftmedical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Seb,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thank you for the advice.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">So I change my test code as you suggested, but the problem still persists.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                JFrameRenderer.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7f0055">this</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">.remove(</span><span style="font-size:10.0pt;font-family:Consolas;color:#0000c0">renderWindowPanel</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">               
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3f7f5f">// renderWindowPanel.Delete();</span><span style="font-size:10.0pt;font-family:Consolas"></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">               
</span><span style="font-size:10.0pt;font-family:Consolas;color:#0000c0">renderWindowPanel</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7f0055">null</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">;</span><span style="font-size:10.0pt;font-family:Consolas"></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;color:black">                vtkObject.</span><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000c0">JAVA_OBJECT_MANAGER</span></i><span style="font-size:10.0pt;font-family:Consolas;color:black">.gc(</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7f0055">false</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;color:black"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The attached shows the renderWindowPanel has not been released after 6 times of button click that triggers replacing the renderWindowPanel object.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Do I miss something?</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thank you,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Kenji</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Sebastien Jourdain [mailto:<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>]
<br>
<b>Sent:</b> Monday, April 18, 2016 4:32 PM<br>
<b>To:</b> Kenji Tsumura<br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
<b>Subject:</b> Re: [vtkusers] Java vtkPanel</span></p><div><div class="h5">
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">Hi Kenji,</p>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">You can look at what we are doing with the delete() method of vtkPanel (knowing that we leak on Linux instead of crashing). </p>
</div>
<div>
<p class="MsoNormal">But I'm guessing I see 3 possible issue in your code.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">1) You should try to detach your renderWindowPanel instance from the parent JFrame.</p>
</div>
<div>
<p class="MsoNormal">2) Then you should set it to null before calling vtkObject.JAVA_OBJECT_MANAGER.gc(false);</p>
</div>
<div>
<p class="MsoNormal">3) And in any case, you should not call Delete() on it.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">I'm thinking your code may cleanup its memory but not the first time you do it. After 3 times, you only cleared the first allocated memory.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Hope that helps,</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Seb</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">PS: If ever you want to contribute your native library loader, please feel free to do so, I can facilitate the process. ;-)</p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">On Mon, Apr 18, 2016 at 2:30 PM, Kenji Tsumura <<a href="mailto:kenji.tsumura@neosoftmedical.com" target="_blank">kenji.tsumura@neosoftmedical.com</a>> wrote:</p>
<div>
<div>
<p class="MsoNormal">Hi,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I have a Java application that use vtkPanel. Precisely, I made a class that extends vtkRenderWindowPanel. When an object of the class is no more used, I would like to dispose the object. But I couldn’t dispose it no matter how. 
 Java VisualVM indicates the object is JNI global reference. So  how can I dispose it? I used the Delete method and called vtkObject.JAVA_OBJECT_MANAGER.gc(false), but it didn’t work (it works for other VTK objects). The attached file is a simple test code
 that demonstrates vtkRenderWindowPanel is never disposed.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I have seen similar post in the past, but never be answered in the way I hope. So I decided to post. I would appreciate any advice.</p>
<p class="MsoNormal">Thank you,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Kenji</p>
<p class="MsoNormal"><span style="color:#222222"> </span></p>
<p class="MsoNormal"><span style="color:black">“The information contained in this communication may be confidential, is intended only for the use of the recipient(s) named above, and may be legally privileged. If the reader of this message is not the
 intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately
 and delete the original message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender.</span></p>
<p class="MsoNormal"> </p>
</div>
<p class="MsoNormal">Disclaimer: The information contained in this communication may be confidential, is intended only for the use of the recipient(s) named above, and may be legally privileged. If the reader of this message is not the intended recipient, you
 are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately and delete the original
 message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender.
</p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">
http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">
http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a></p>
</div>
<p class="MsoNormal"> </p>
</div>
</div></div></div><div><div class="h5">
Disclaimer: The information contained in this communication may be confidential, is intended only for the use of the recipient(s) named above, and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified
 that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately and delete the original message and any copy
 of it from your computer system. If you have any questions concerning this message, please contact the sender.
</div></div></div>

</blockquote></div><br></div>