This content has been marked as final. Show 7 replies
808909 wrote:The JVM allocates continuous virtual memory at the start of the program and only releases it when it exits.
~ Does ever CMS collector give back memory to OS. Is that a feature of CMS or not?
This virtual memory is populated with resident memory when it is used. This is not something the application manages, but the OS.
~ In Solaris we have not seen CMS ever give back memory to OS. At some time when application needed memory it reached its max and then thats all, there is nothing wrong in it. Application required so jvm took from OS. But later GC cleaned up and when used heap is only 200M , remaining 2.2G from my memory still with JVM, it is not used also. Never went back to OS.The OS can reclaim memory by swapping out the unused pages of application, however this can hurt performance if you ever need the memory again. If you don't see the application being swapped out, that is because the memory wasn't needed.
~ We saw lot of people talk about these attributes which makes jvm to shrink MaxHeapFreeRatio, MinHeapFreeRatio . We did tried with these but no use at all. Does CMS use these two attributes?It does use them, but it controls when it should run. It doesn't control any interaction with the OS.
But we saw memory giving back to OS by using UseParallelGC , here are the VM options usedI don't believe it does. You may have seen the resident memory reducing because the demands of another application pushed the memory out or your file cache grew.
-XX:MaxGCPauseMillis=3000 -XX:GCTimeRatio=19 -XX:+UseParallelGC -XX:+UseParallelOldGC"
BTW: It might be worth upgrading your Java to update 25 as update 19 is fairly old. (Though it won't make any difference to this question)
Its not a question of how does it matter. We want to know the behavior CMS collector. I have a situation where I am using CMS and some point of time app needs more memory its takes from OS. Thats very good no issues with that. But it never give's back to OS.
I did lot of google before coming here. most of the people are talking about -XX:MaxHeapFreeRatio=<value> and -XX:MinHeapFreeRatio=<value>. I don't see these two attributes are doing that.
Thanks for your reply
See this link where I shared a memory comparison between CMS and ParallelGC. I used VisualVM for this. You can clearly see in ParallelGC graph total heap size certainly came down. The same I never saw with CMS. Do you agree?