Re: Resource Leak


John J Brecht wrote:

after reading this:
and very briefly skimming through this link that it points to:

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 Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307

  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: