1

I have java web (tomcat) application that consumes 10G of heap memory (represent data structure in memory). But it works when I will set e.g. Xmx to 20G.

When I set heap memory e.g. to 11G my application can not load all data - it enters in continuous full gc. Suppose that garbage collector also need memory to make full gc efficient. Does it correct? How much memory I should add for efficent work of gc? Thanks.

user710818
  • 23,228
  • 58
  • 149
  • 207

2 Answers2

2

Its better if you set permanent generation allocation as you have lots of data to load. Actually this permanent generation is used to hold reflective data of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations.

-Xms10G -Xmx20G -XX:PermSize=5G -XX:MaxPermSize=12G
Subhrajyoti Majumder
  • 40,646
  • 13
  • 77
  • 103
2

To find out optimal OldGen size:

  1. Enable GC logging -XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -XX:+HeapDumpOnOutOfMemoryError -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion

  2. Calculate Live Data Size = occupancy of the old OldGen after a FullGC (see Advanced JVM Tuning for more details). Btw. try to get avg. by observing the OldGen occupancy after several FullGC cycles.

  3. optimal OldGenSize == 2x to 3x of the Live Data Size.

Aleš
  • 8,896
  • 8
  • 62
  • 107