So I'm doing some memory leak checks
I always print the amount of RAM I have supposedly used onto the screen, in MB:
ram_occupied = (int)(Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory())/1024/1024;
always trusted this is correct.
now it build up after time, gc makes it lower sometimes, all fine and good.
so now I want to do some analysis, I use Eclipse's Memory Analyzer and "Acquire Heap Dump", right
however the heap dump is only 3.4 MB of size - not telling me much, while I thought I had accumulated like 70 MB by now, as told by the code above
this btw also applies to jvisualvm and such
if I run the GC manually by using the button in visual vm for example, used ram shrinkes to about 4MB, from for example 70MB
this leds me to believe that the reason is, that most of it (66 MB) is just junk and not dump @ heap dump therefore - and stuff I don't need to care about
my ram usage climbs 1-2MB per second on average, I use G1GC, and it can clean up until like 4MB - it doesnt always clean up everything, due to G1 I guess