Re: Memory leak when using offscreen rendering

Hello Bill,

I have already changed the DisplayImplJ3D and the VisADCanvasJ3D for my
own, so I have no problem with offscreen rendering. I only wanted to
submit the problem, to improve the visad library.

But I would do it in another way than yours. I would generally call
removeNotify() instead of stopRenderer() in VisASCanvasJ3D. It also works
when not using offscreen rendering.

   public void stop() {
      removeNotify(); // works also when not using offscreen rendering
      display = null;
      displayRenderer = null;
     if (component == null) {
       display.destroyUniverse();
     }
     . . .

And instead of adding a new method 'destroyUniverse' in DisplayImplJ3D, I
suggest to add this in the destroy() method:

  public void destroy() throws VisADException, RemoteException {
    // WLH 17 Dec 2001
    // ((DisplayRendererJ3D) getDisplayRenderer()).getCanvas().stop();
    ((DisplayRendererJ3D) getDisplayRenderer()).destroy();
    if (universe != null) 
        universe.destroy(); // when offscreen
    super.destroy();
  }

I using both rendering methods (offscreen and 'normal') and I don't want
to call different methods for destroying, depeding on the rendering mode.

Cheers,

Hannes

-----Original Message-----
From: Bill Hibbard <billh@xxxxxxxxxxxxx>
To: Johann Liedl <JLiedl@xxxxxxxxxxxxxx>
Date: Wed, 12 Mar 2003 11:51:49 -0600 (CST)
Subject: 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
> >
> >


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: