Re: Resource Leak

John-

John J Brecht wrote:

after reading this:
http://java.sun.com/products/java-media/3D/java3dfaq-1.3.html#memory
and very briefly skimming through this link that it points to:
http://developer.java.sun.com/developer/technicalArticles/ALT/RefObj/index.html

I did a quick experiment and added these two lines:

               xmap = null;
               xmap = new ScalarMap( RealType.Time, Display.XAxis );

just before the line:

               xmap.setRange(then, now);


This would eliminate the problem because the new map has not
been added to the display, so it doesn't have to go through any
of the display logic which uses Java 3D.


and it looks like the memory problem goes away. Chances are that Java3D (especially with VisAD on top of it) is chock full of these "weak" and "phantom" references mentioned in the article. I didn't read enough of the article to understand how to properly use the Reference API, but I imagine building that into VisAD might be the proper solution to this problem. Meanwhile, trying setting anything to null that you can!


I agree with your assessment, but you have to be careful what
you set to null.  Creating a new ScalarMap creates a new Object
which is not what you want in this case.

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************