Issue
I was wondering. I have a simple Java web project with a servlet. When no users are using it (I host it local on GlassFish) I still see a sawtooth pattern in the memory usage of the process. I can't seem to understand what the JVM is doing? I understand the normal flow of the memory used by JVM. The heap is getting filled with objects the application is creating. At a certain point the heap reaches a point where the garbage collector comes in, which will remove all the 'cached' objects which no longer are used, so that new objects can be created and can be filled in the heap size.
What I wonder is, what is the JVM doing all the time when it's idle?
EDIT:
Like I said in the comments. I created a very simple Java application in Eclipse which showed a Swing window saying 'hello world'. When I watch the memory usage of the JVM in Java VisualVM, I see the same sawtooth pattern.
Solution
It turns out that VisualVM is the guilty one. This is because VisualVM constantly asks the JVM what it's statistics are, so the JVM creates objects to give the information to VisualVM.
Thanks to Peter Lawrey
Answered By - Rens Groenveld
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)