This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
Joined: Apr 13, 2004
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?