I was testing performance of Guava cache by loading 5000 objects in cache using 50 threads using ExecutorService. I wanted to see the heap occupied by the cached objects.
It looked as though the cached objects were eating up 25MB.
Later, I put a Thread.sleep on the main thread to sleep the application for 10 minutes, so that I could sample the memory etc.
Surprisingly, even when the application is on sleep, it generates 20MB of garbage every 4 minutes. Since there is a GC operation every 4 minutes, I am seeing a Sawtooth wave in the used heap graph.
Why does java generate 5MB of garbage per minute in an idle application?
UPDATE: I ran just a main method with only a call to Thread.sleep for 10 minutes.
Memory allocation is 4 MB per minute.
Below is the memory sampler screenshot.
Looks like only the RMI TCP connection thread which is causing all the activity.
Is it just the fact that we are observing with VisualVM causing all that activity? Or is it regular jvm activity?