How does Java manage memory? I got curious after seeing a live profiling session
So I just found out NetBeans has a great live profiling tool so I can manage all my memory-usage and such.
What I noticed was my virtual memory going up slowly as I increased the connections to the server, but after a while (after closing the connections) it got to a critical point where the memory sort of 'resets'.. Can someone explain to me whats happening? Is this the garbage collector doing it's thing?
Re: How does Java manage memory? I got curious after seeing a live profiling session
Likely, yes. As you open more and more connections, your Java app requires more memory to maintain each connection. However, once the connection is closed the JVM won't immediately reclaim the memory. Instead, every now and then it will call the garbage collector and that will go around looking for unused memory and reclaim it. It's possible to manually force the garbage collector to start, though it's generally not advisable.
Re: How does Java manage memory? I got curious after seeing a live profiling session
the graph of the memory in the JVM is like of SAW TOOTH (this is in Ideal case). when the memory is about the completely filled by the objects then the JVM invokes the Garbage Collector to remove the Unreferenced objects and frees the memory so that there is memory for the new objects to be created.