17
votes

I have the following memory options configured:

export MEM_OPTS="-Xmx2560m -Xms2560m -XX:NewSize=786m -XX:MaxNewSize=786m -XX:+UseTLAB -XX:MaxPermSize=512m"

My GC parameters are below:

export GC1_OPTS="-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:**CMSInitiatingOccupancyFraction=50** -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:+UseAdaptiveGCBoundary" export GC2_OPTS="-XX:+ExplicitGCInvokesConcurrent"

When CMS runs, will it run after 50% of 2560 MB or will it run after 50% of 512 MB of memory? What is the concept?

My total heap memory would be equal to 2560 + 786 + 512 MB, right?

Or is "-XX:NewSize=786m -XX:MaxNewSize=786m" for NON-heap?

Please explain the concept.

1

1 Answers

30
votes

Neither. It will be eligible to run after the occupancy of the old generation reaches 50%, where the size of the old generation is the size of the heap minus the size of the new generation: 2560m - 786m = 1792m, so that would be after the old generation reaches 896m. But that's not always the only parameter. You may want to add -XX:+UseCMSInitiatingOccupancyOnly if you want it to become the only parameter (though in my experience, CMS actually triggers at the threshold, even without it).

To summarize:

  • -Xmx is the total heap memory
  • -XX:NewSize / -XX:MaxNewSize is the range of the size of the new generation inside that heap
  • the difference is the range of the size of the old generation
  • -XX:PermSize / -XX:MaxPermSize is the range of the size of the permanent generation, which is the non-heap memory