Here is some code that creates a condition similar to what I describe in the
previous message.  This creates a number of SimpleUniverse instances (5 by
default) and then gets rid of them.  It does not itself show that there are
SimpleUniverses that stay around, but using a Heap analyzer like OptimizeIt
Profiler reveals that.  In this example, the memory consumed by the
remaining SimpleUniverse instances is not much since nothing is added to the
universe, but where I first encountered this, even after cleanup() is
called, they still consume several MB each.

I found that having no time between calls to cleanup() causes all of the
instances to go away, but in practice that is not feasible since the
remaining ones should still stay for awhile.

To my understanding, I am doing what I am supposed to do to get rid of the
universe instances.  If I am not I would appreciate somebody advising me to
what else I need to do.


import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.media.j3d.Canvas3D;

public class SUCleanup {

  public static void main(String[] args) {

    int count = 5;
    long pause = 1000;
    if (args.length > 0) {
      count = Integer.parseInt(args[0]);
    }
    if (args.length > 1) {
      pause = Long.parseLong(args[1]);
    }
    System.out.println("Creating " + count + " SimpleUniverse instances");
    System.out.println("Pausing " + pause + " milliseconds between cleanup()
calls");

    try {
      SimpleUniverse[] universeArray = new SimpleUniverse[count];
      for (int i=0;i<count;i++)
        universeArray[i] = new SimpleUniverse(new
Canvas3D(SimpleUniverse.getPreferredConfiguration()));
      System.out.println("Created " + count + " instances");

      for (int i=0;i< count; i++) {
        Thread.sleep(pause);
        universeArray[i].cleanup();
        universeArray[i] = null;
        System.out.println("Universe " + i + " cleanup() called");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    System.out.println("Finished");
  }
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to