Just a quick thought - and not really a fix as such, but why create and
destroy the scene like this? The scene, and the Universe which contains
it is best thought of as pretty persistant, and independent of a
view/canvas if at all possible. Then all you have to do is attach and
detatch views with their associated Canvas's as required.

Lewis.

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED] On Behalf Of Glenn Pinkerton
Sent: 08 September 2003 21:45
To: [EMAIL PROTECTED]
Subject: [JAVA3D] major memory leak


Hello,

I saw some discussion of a major memory leak in java3d, and I think I am
running into the same problem.

I am currently just creating a swing JFrame with a panel inside it.  The
panel parents the canvas3d.  Here is the constructor for the panel.

    J3DPanel ()
    {
        setLayout (new BorderLayout());
        GraphicsConfiguration config =
            SimpleUniverse.getPreferredConfiguration ();
        canvas = new Canvas3D(config);
        add (BorderLayout.CENTER, canvas);
        canvas.setBackground (new Color (240, 240, 240));
        universe = new SimpleUniverse (canvas);
    }


When the JFrame that parents the panel is disposed of by the user, the
following cleanup code is called.  I tried to pattern this after some of
the ideas in the interest group discussion.

private void cleanup ()
    {
        System.out.println ("3d cleanup called");
        System.out.flush ();
        if (universe != null) {
            universe.removeAllLocales ();
            universe = null;
            canvas = null;
        }
        System.gc();
        System.gc();
    }

I know the cleanup is called because the println is executed.

When I repeatedly create a scene and dispose of the frame, I lose
several megabytes of memory for each repetition.  This is a major
problem that makes using Java3d for a real world application untenable.
I recall from my reading that Sun had this as a bug.  Is there a fix for
the bug yet? Is there any other workaround for this?  Is there some way
to use the VirtualUniverse class rather than the SimpleUniverse class to
get around the problem?


Thanks,

Glenn

========================================================================
===
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".

===========================================================================
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