I've got a program that obtains information from various sensors. It works fine, but I'm paranoid about the garbage collection not kicking in later on in the future.
Using VisualVm, I've noticed that every time it gets a sample of the heap, a few bytes keep on being allocating. I cannot see when the GC will kick-in to free up memory.
Because I've this I decided to code this simple program and observe the contents of the heap:
Here are my results:
As you can see, the memory usage keeps on increasing (only a few bytes).
I'm thinking if this is to do when the thread it sleeping and being woken up. The few bytes is the overhead of this (I could be wrong)
Does the GC kick in when the memory usage exceeds a certain threshold.
The last time I played with this I game to the conclusion the leak i was measuring was visual VM i.e the RMI conversation between the two.
When GC kicks in depends on what GC you have selected if your attached to the process you should be able to force GC. I suspect you have the default collector and I would expect your saw tooth graph to rise to a point and then drop all the way down and start all over.
Try turning on gc logging then get hold of a visualiser for it like gcviewer if you get a nice straight blue line forget about it.
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5