Re: Memory leak when using offscreen rendering

Hi Johann,

I have put versions of DisplayImplJ3D.java and
VisADCanvasJ3D.java on:

  ftp://ftp.ssec.wisc.edu/pub/visad-2.0/untested/

with modified versions of you changes. Specifically,
there is a new method in in DisplayImplJ3D:

  public void destroyUniverse() {
    if (universe != null) universe.destroy();
  }

and in VisADCanvasJ3D:

  public void stop() {
    try {
      stopRenderer();
    }
    catch (IllegalStateException e) {
      removeNotify();
    }
    display = null;
    displayRenderer = null;
    if (component == null) {
      display.destroyUniverse();
    }
    else if (component instanceof DisplayPanelJ3D) {
      ((DisplayPanelJ3D) component).destroy();
    }
    . . .

Please let me know if these changes solve your problem.

Cheers,
Bill

On Wed, 12 Mar 2003, Johann Liedl wrote:

> Hello,
>
> When using offscreen rendering, there are 2 problems with memory
> when destroying the 3D scene:
>
> 1. When invoking DisplayImplJ3D.destroy(), I get a 'IllegalStateException'
> thrown in Canvas3D.stopRenderer().
> Suggested solution: In the VisADCanvasJ3D.stop() method, instead of
> calling stopRenderer(), the method removeNotify() should be invoked.
>
> 2. The UniverseBuilderJ3D.destroy() method is never reach, because the
> attribute 'component' in VisADCanvasJ3D is null.
> Suggested solution: Add a attribute 'universe' in DisplayImplJ3D, which
> has e reference to the universe and is assign in the initialize(..)
> method. When the DisplayImplJ3D.destroy() method is invoked, call also
> universe.destroy();
>
> Cheers,
>
> Hannes
>
>