lowLatency
lowLatency

Reputation: 5654

Java heap Xmx flag and max size of diff spaces of my app in prod

a) As I know -Xmx represents max heap.
Is it a combination of young generation(eden+survivor) and tenured generation(old generation) and perm gen ?

b) How can I now the min/max size of different spaces of memory of the application which is in UAT/Prod 1) eden space
2) survior space
3) tenured
4) perm gen

Upvotes: 2

Views: 1120

Answers (4)

Trying
Trying

Reputation: 14278

Perm generation is a separate space allocated via MaxPermSize. This is not included in -Xmx

-Xmx includes one Eden space , two survivor space and old generation.

You can even calculate the individual spaces by knowing --xx:NewRation:. This is ratio between the young and old generations. For example if n is 3 than ratio is 1:3 and the combined size of Eden and survivor spaces is one forth of the total size of the young and old generation.

You can also use jstat command to know individual sizes and also tools like VisualVM can help you great deal. Just look in to the picture which states you pictorial representation of individual space details.

enter image description here

Upvotes: 1

Hari
Hari

Reputation: 1054

The max heap size allocated via -Xmx is a combination of the young generation and the tenured generation. permgen space is allocated separately, using the -XX:MaxPermSize option to the JVM. This question is answered here:

Is permgen included in -Xmx?

One good way to determine the sizing of the different generations in the heap in a JVM - particularly on a remote server - is to use the jmap command:

http://docs.oracle.com/javase/6/docs/technotes/tools/share/jmap.html

Here's some sample output from a server that I administer:

$ sudo jmap -heap 28579

Attaching to process ID 28579, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_07-b03

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 6127878144 (5844.0MB)
   NewSize          = 2147483648 (2048.0MB)
   MaxNewSize       = 2147483648 (2048.0MB)
   OldSize          = 3980394496 (3796.0MB)
   NewRatio         = 15
   SurvivorRatio    = 1024
   PermSize         = 314572800 (300.0MB)
   MaxPermSize      = 314572800 (300.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 2145452032 (2046.0625MB)
   used     = 2130014864 (2031.3404693603516MB)
   free     = 15437168 (14.722030639648438MB)
   99.28047014010332% used
Eden Space:
   capacity = 2143420416 (2044.125MB)
   used     = 2130014864 (2031.3404693603516MB)
   free     = 13405552 (12.784530639648438MB)
   99.37457197384462% used
From Space:
   capacity = 2031616 (1.9375MB)
   used     = 0 (0.0MB)
   free     = 2031616 (1.9375MB)
   0.0% used
To Space:
   capacity = 2031616 (1.9375MB)
   used     = 0 (0.0MB)
   free     = 2031616 (1.9375MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 3980394496 (3796.0MB)

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533442

You can watch these sizes externally using jstat like

jstat -gc {pid} 10s

You can find out the pid by using

jps -lvm

Upvotes: 2

alain.janinm
alain.janinm

Reputation: 20065

If you want to know the size of those space use the java option -verbose:gc -XX:+PrintGCDetails. This documentation will help you understand how the differents generations work.

Upvotes: 1

Related Questions