• Post Reply Bookmark Topic Watch Topic
  • New Topic

Garbage Collection & Memory Problem.  RSS feed

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a custom java.awt.Canvas that implements Runnable and I'm using it to draw some images on and do some simple animation.
Now this Canvas creates a lot of in memory images and I give the user the option to change the color of these images with a menu option.
What I've been doing is to remove the canvas from the layout and create a new one with the new colors that the user requests.
The problem is that I seem to be running out of memory after changing the colors a few times.
How can I be sure that all of the images that got created with the Canvas are destroyed and the memory is reclaimed by the VM?
If I just set the reference to the Canvas to null will that return the memory that was being used by the images when the garbage collector comes around?
Thanks,
Drew
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!