> Date:         Thu, 3 Jul 2003 18:08:41 +0200
> From: Bernd Fondermann <[EMAIL PROTECTED]>
>
> Detaching/Reattaching plus changing the scene graph in between not only is
> memory consuming, it is also time consuming. (Btw, freeing memory is time
> consuming, too.)
> Since a servlet is meant to serve multiple pages (jpgs in your case) per
> second in parallel (isn't it?), you surely will run into scalability problems
> here. It's by design.
> I use the same approach by avoiding detaching, by running j3d in a separate
> process and by propagating the rendered image from j3d process to the servlet
> engine process.

Interesting... do you use a single JVM instance to run all J3D requests
separate from the servlet engine, or multiple JVM instances for a set of
requests?  What kind of performance do you get?

There is at least one known memory leak in J3D 1.3.1: Bug 4884065 -
"Memory leak in SetLiveState when branchGroup remove."  The memory
leaked should be reclaimed the next time a branchgroup is created, but
there could be other undiscovered memory leaks that might be causing
problems when invoking J3D programs multiple times within the same JVM.
Until they're resolved, running J3D in a separate process could be a
good workaround.

The basic problem for J3D in a servlet environment is its usage of
persistent threads -- the Renderer thread doesn't die until
System.exit() is called, but that's not possible in a servlet that
depends upon the current JVM instance to service multiple requests.  So
garbage collection and proper clean up after servicing J3D requests is
crucial.

SimpleUniverse.cleanup() should help, and non-SimpleUniverse clients can
just do what it does: release all Canvas3D instances from all Views,
release all ViewingPlatforms and Maps from any Viewers, and release all
Locales from the universe.

    public void cleanup() {
        viewer[0].getView().removeAllCanvas3Ds();
        viewer[0].setViewingPlatform(null);
        removeAllLocales();
        Viewer.clearViewerMap();
    }

-- Mark Hood

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