Re: Out of Memory Error

Hi Luke & Suzanne,

I am not sure where the memory leak is. However, it should not
be necessary to completely destroy your DisplayImpl in order to
change its properties. The following two calls should do it:

  display.removeAllReferences();
  display.clearMaps();

Please let us know if these don't solve your problem.

Good luck,
Bill

> I have a JFrame that contains the VisAD Display for 2D plotting and a 
> JMenuBar.  In the menus, I allow the user to change the color of the
> data, background, x-axis, y-axis, and box.  I also allow the user to change 
> the axis scale.  With the background and box colors it seems easy
> to change the color using:
> 
>     
> display.getDisplayRenderer().setBackgroundColor(backgroundColors[0],backgroundColors[1],backgroundColors[2]);
>     display.getDisplayRenderer().setBoxColor(boxColors[0], boxColors[1], 
> boxColors[2]);
> 
> But for the other properties , not knowing another way to change them in the 
> display once the user changes one of the above properties using
> the menu, I
> invoke the following code:
> 
>     try {
>       display.removeAllReferences();
>       display.destroy();
>       this.getContentPane().removeAll();  // JFrame contents
>       this.showDisplay();  // With the property changes from the menu, it 
> draws another graph all over again
>     } catch (RemoteException remoteEx) {
>       
> this.applicationFeedbackFile.replaceSelection(remoteEx.getLocalizedMessage());
>     } catch (VisADException visadEx) {
>       
> this.applicationFeedbackFile.replaceSelection(visadEx.getLocalizedMessage());
>     }
> 
> and display is decalared somewhere as:
> 
> DisplayImpl display;
> 
> 
> I am trying to completely remove the previous display and redraw another.  
> After a few of these as the user changes many of the graphs
> properties, I get the following error of which some of the trace goes through 
> visAD, but alot through Java, so I am not sure where the problem
> really lies.  Is there some memory that visAD uses that I am not properly 
> cleaning up?
>
>
> Exception occurred during event dispatching:
> 
> java.lang.OutOfMemoryError:
> 
>  at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:48)
> 
>  at java.awt.image.Raster.createPackedRaster(Raster.java:404)
> 
>  at 
> java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:637)
> 
>  at sun.awt.windows.WComponentPeer.createImage(WComponentPeer.java:193)
> 
>  at java.awt.Component.createImage(Component.java, Compiled Code)
> 
>  at java.awt.Component.createImage(Component.java, Compiled Code)
> 
>  at java.awt.Component.createImage(Component.java, Compiled Code)
> 
>  at java.awt.Component.createImage(Component.java, Compiled Code)
> 
>  at java.awt.Component.createImage(Component.java, Compiled Code)
> 
>  at java.awt.Component.createImage(Component.java, Compiled Code)
> 
>  at visad.java2d.VisADCanvasJ2D.createImages(VisADCanvasJ2D.java, Compiled 
> Code)
> 
>  at visad.java2d.VisADCanvasJ2D$1.componentResized(VisADCanvasJ2D.java:97)
> 
>  at java.awt.Component.processComponentEvent(Component.java, Compiled Code)
> 
>  at java.awt.Component.processEvent(Component.java, Compiled Code)
> 
>  at java.awt.Container.processEvent(Container.java, Compiled Code)
> 
>  at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
> 
>  at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code)
> 
>  at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
> 
>  at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
> 
>  at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java, 
> Compiled Code)
> 
>  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
> 
>  at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)

-- 
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


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