| || |
Slow, memory-hogging Java app\'s - a fix
Most if not all of us have run into problems with slow operations and memory issues with
Java-based applications. The longer you run them, the more memory they eat up, the slower they get, and the more bizarre and inconsistent their behavior becomes.
I discovered an easy way to alleviate these issues for Window-based systems. All you have to do is periodically minimize the Java MainWins, then restore only the one that you're currently using. I've seen as much as 40 meg of memory released by a minimized application. You'll find that interactive responsiveness is dramatically improved.
Minimizing apparently tells the operating system that you're 'done' with the application; that it can release all accumulated, unused memory. Note that this also works with Window's-based applications but since they are inherently better at memory management, the effect is less
For my own operations I've implemented a minimize_all() function that drives the NT/2000 Task Manager. It runs at the beginning of every TestCaseEnter() and at every 10-count inside every application-interactive loop.
You can experiment with this solution by simply opening up the Task Manager and taking note of the Memory Usage on the Processes tab for your application before and after minimizing and after restoring it. The application will get slightly larger than its minimized size after it is restored, but it will almost always be much smaller than what it was before it was minimized.
Note that using the "Minimize All Window" from a TaskBar right-click, while convenient, does not elicit the same effect.
Re: Slow, memory-hogging Java app\'s - a fix
When a friend of mine found it, I asked around and nobody knew WHY it was doing that. Whenever I did it, it always gave me a feeling as if I was "cheating" and I stayed away from it because of a lack of explantion. After some investigation I noticed one thing.
When the window is restored after minimized, you will notice a large chunk of physical memory pages to virtual memory (on taskmanger you can add a VM coluum). I am not too experieneced with memory leak testing, but I would assume that objects stored in physical or virtual memory would be the same; therefore memory is still leaking.
The ultimate test, which I never got a chance to do, is get a application that eventually gets the "OUT OF MEMORY" exception and right before the point of destruction (for my app is was 86 megs), minimize it till see if the fault DOES not occur.
Anyhow, I too am on the quest of low memory leaking with JAVA+SILK