My Eclipse footprint is steadily increasing from 500MB to >1GB without me doing anything in particular – just running some log heavy programs. Doing a manual GC, closing and reopening projects does not help at all, once it’s over 1GB it stays there.
I’ve run jvisualvm and found out from the heapdump that hundreds of megabytes are char[] representing log output.
I make it a habbit to close all the consoles of stopped processes, so it’s not that.
Console buffer is set to 1MB (characters). I’ve closed the console view and reopened it again.
I can paste my particular eclipse.ini but I’ve tried different GC and memory settings, different JVMs, different Eclipse versions – behavior is still the same.
To me it seems that the logs are getting stuck with a reference somewhere and never get released. Is anyone else having this problem? Is there a setting somewhere to release memory from old console views?
Short answer: heap size is not shrinking, only growing.
Long answer:
In the end it seemed like a combination of factors. I’m not completely sure what the JVM default options should be, but my XP machine has the Windows performance optimisation set to ‘Server’/’Background applications’. I believe this also causes the JVM to default to the ‘-server’ option instead of the ‘-client’.
The -server option does not allow the heap to shrink.
As far as I’ve found out, parallelGC does not allow the heap to shrink.
The default values for XX:MaxHeapFreeRatio (70) and XX:MinHeapFreeRatio (30) are pretty lazy in giving up free memory. Setting them to 20/10 will result in a heap size closer to actual usage.
Why is all of this important? Well, if you are developing a desktop application in Java your client might get upset with the ever-increasing memory usage and blame your bad programming. Kind of like what happens with Firefox.