0
votes

Heap memory is divided into Young Gen, Old Gen and PermGem.

In young gen, one eden space and two survivor spaces are allocated. According to GC in our machines, one survivor space should always be available so that the next live nodes references can be stored there when GC marks the already present references (scans) in the young gen (eden space + 1 survivor space) and upgrade them to old gen.

First question is, is this understanding correct?

If yes, at all the times some portion of Young Gen will be vacant/available in the form of 1 survivor space. So how to see in GC Logs that the young gen is full (i.e. GC is triggered) or that is misleading? which means only usable young gen memory is shown to us in GC logs.

How to analyse the Heap memory is full i.e. OutOfMemory when some portion of Young Gen will always be having some vacant space, hence the all around heap memory.

Thanks in advance.

2
No. I know the basics of it. Wanted to know more about Young Gen only. Specially the two Survivor spaces in the Young Gen and how they behave and when we can say the Young Gen is full. I may have to reframe my question as it is little confusing.Amrit Sarkar
AFAIK, during a minor collection, the survivors of both, Eden and S0 are copied to S1, before S0 and S1 are swapped. Only objects surviving a configurable number of minor collections are promoted to the next generation. Hence, there’s a possibility that S1 has not enough room for all survivors, which would require early promotion of survivors.Holger

2 Answers

0
votes

There are 2 kinds of GC collections

  1. Minor GC - this occurs when the young generation fills up
  2. Full GC - this occurs when the tenured or the old generation fills up.
    An OutOfMemory occurs when there is no space left on the heap to move objects into the old generation.
    You should read up more on Java GC process. You can start with - http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

To read and analyze the GC logs you can refer to How to read a verbose:GC output?

0
votes

Assuming you're using hotspot then logging with -XX:+PrintGCDetails -XX:+PrintHeapAtGC should be verbose enough to cover all the things you're interested on.