I was doing a quick experiment to see how my algorithm's memory performance looks like. The input is about 2 Mb and the algorithm takes about 1 second to run it. I ran this in a loop for 500 times to be able to look at the memory allocation.
This is how jConsole shows the memory usage:
As you can see heap memory usage increases (kinda exponentially) every two times before GC starts (even though the input is the same).
Does anybody know if this is expected and why it happens? Is it some optimization done by JVM?
Thanks!