File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes memory not releasing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "memory not releasing" Watch "memory not releasing" New topic

memory not releasing

Eric Braun

Joined: Apr 13, 2004
Posts: 11
We have a pretty complicated swing application that is eating up memory. We found some memory issues, but still have this remaining. We allocate 128mb of RAM to the heap. We see the garbage collector doing the work from 20 to 127mb because the the memory will go up and down. Once we hit the 128mb size, the memory never goes down and just stays there. The only way we can clear it out is to restart the swing application.

Any ideas? Thanks in advance!
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
What are you using to determine the use of memory?

If you are using from the operating system it's expected that you will see the heap grow to 128 and stay there. The reason is that the gc will reclaim memory, but that memory is generally saved within the JVM and not returned to the system. If you are not having OutOfMemory errors and not having performance problems I wouldn't worry about it.

On the other hand if you are using some tool to see the heap usage of the JVM I would get a profiler and start looking for where the memory is going.
Eric Braun

Joined: Apr 13, 2004
Posts: 11
Yes, we are wathinc the cpu system resources and we are experiencing OutOfMemory issues.

If we let them open too many jPanels (each one is taking a good chunk of memory), they get the OutOfMemory. If we limit them to a predefined amout of JPanels, then we eliminate the memory error.

Also, do you know if the inner classes used for the swing objects actually get destroyed when the class is destroyed? I am wondering if I create a class for each form that holds the inner classes and then manually destroy that class, if that will give up memory?
I agree. Here's the link:
subject: memory not releasing
It's not a secret anymore!