Hi Desiree,

   Setting

  u.getViewer().getView().removeCanvas3D(offScreenCanvas3dTest);

  may not enough. The Viewer still has reference to the old
  offScreenCanvas3dTest so it is not GC. Please check out
  the source code of utility.

  There is no API to remove canvases from Viewer once it is
created. So the Viewer has to remove from the scene graph
to let it GC (so offScreenCanvas3dTest can GC also).

To do this, try

  simpleuniverse.getViewer().setViewingPlatform(null);

  which will remove the Viewer reference from ViewingPlatform.
Also check in your program to see if there is reference to
Viewer.

There is also bug 4507374 - OffScreenBuffer Memory Leak
which is fixed in the next v1.3 beta release.

Thanks.

- Kelvin
---------------
Java 3D Team
Sun Microsystems Inc.



>Delivered-To: [EMAIL PROTECTED]
>X-Sender: [EMAIL PROTECTED]
>MIME-Version: 1.0
>Date: Tue, 16 Oct 2001 17:24:40 +0200
>From: Desiree Hilbring <[EMAIL PROTECTED]>
>Subject: [JAVA3D] OffScreenCanvas3D
>To: [EMAIL PROTECTED]
>
>Hi,
>
>I still have problems with the memory usage, during printing.
>I looked again at the PrintCanvas3D example. In this example there is
>created once an OffScreenCanvas3D object, and this is reused every time
>for printing (Memory increases once and then stays stable at a higher
>level).
>Ok I guess, I could change my application, so that such an object is
>created only once as well. Unfortunately the creation costs memory and I
>do not want to increase my memory for the rest of the operation time, only
>because, someone wants to print.
>Is there any possibility to get rid of the OffScreenCanvas again, and free
>the memory, so that my application has some memory left for other tasks?
>
>I tried the following:
>
>        basically I tried to remove the OffScreenCanvas3D from the view
>        after printing, set it to null and then call the Garbage
>        Collector.
>
>
>I really would appreciate some help, thanks Desiree
>
>
>        configTest = SimpleUniverse.getPreferredConfiguration();
>        offScreenCanvas3dTest = new OffScreenCanvas3D(configTest,true);
>        // Set the off-screen size based on a scale factor times the
>        // on-screen size
>
>        sOn = c.getScreen3D();
>        sOff = offScreenCanvas3dTest.getScreen3D();
>        dim = sOn.getSize();
>
>        dim.width *= OFF_SCREEN_SCALE;
>        dim.height *= OFF_SCREEN_SCALE;
>        sOff.setSize(dim);
>        sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() *
>                                    OFF_SCREEN_SCALE);
>        sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() *
>                                         OFF_SCREEN_SCALE);
>        // attach the offscreen canvas to the view
>        u.getViewer().getView().addCanvas3D(offScreenCanvas3dTest);
>
>        Point loc = c.getLocationOnScreen();
>        offScreenCanvas3dTest.setOffScreenLocation(loc);
>        dim = c.getSize();
>        dim.width *= OFF_SCREEN_SCALE;
>        dim.height *= OFF_SCREEN_SCALE;
>
>        addBackgroundNode();
>
>        //Background testBack = new Background(new
>Color3f(1.0f,1.0f,1.0f));
>        //offScreenCanvas3d.setBackgroundNode(testBack);
>        u.setJ3DThreadPriority( Thread.currentThread().getPriority() );
>        bImage = offScreenCanvas3dTest.doRender(dim.width, dim.height);
>        bImage.flush();
>
>        removeBackgroundNode();
>
>        u.getViewer().getView().removeCanvas3D(offScreenCanvas3dTest);
>        offScreenCanvas3dTest = null;
>        configTest = null;
>        sOn = null;
>        sOff = null;
>
>        System.gc();
>        System.runFinalization();
>
>oooooooooooooooooooooooooooooooooooooooooooooooo
>Desiree Hilbring
>
>Institut fuer Photogrammetrie und Fernerkundung
>Universitaet Karlsruhe, Germany
>email: [EMAIL PROTECTED]
># 0721 6083676
>oooooooooooooooooooooooooooooooooooooooooooooooo
>
>===========================================================================
>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