views:

23

answers:

1

I know about flag -XX: PretenureSizeThreshold which can be used to set to limit the size of allocations in YG.

Apart from that is there any other scenario/condition where new objects can be allocated space from tenure space ?

what heppens if new object size is larger than the eden space ? will the Young generation GC happens or the object is allocated from tenure area?

+1  A: 

what happens if new object size is larger than the eden space ?

There are a number of things that could happen:

  • If there is enough free memory in the Old space, the object could be allocated there.
  • If the current heap size is smaller than the maximum heap size, the GC could be run and the heap expanded. This might result in the New space being big enough for the object.
  • If there is not enough space in either Old or New space after running the GC, then an OOME will result.

The actual answer is JVM version dependent; e.g. see question 29 of this FAQ which says what happened (respectively) in HotSpot 1.4.2 and earlier Sun JVMs.

Stephen C