File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Garbage Collection & Memory Problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Garbage Collection & Memory Problem." Watch "Garbage Collection & Memory Problem." New topic
Author

Garbage Collection & Memory Problem.

Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
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
 
 
subject: Garbage Collection & Memory Problem.
 
Threads others viewed
Getting System.gc() to run....
How to change the color of an image?
Memory Leak
How to force garbage collection in jdk 1.5
TextField background color inconsistencies
developer file tools