Roy Zhang
Roy Zhang

Reputation: 41

When will G1 GC allocate objects in old generation directly

In my gc log, there are many objects are allocated to old generations (ALLOC(Old) logs), current threshold is 15, my objects age is only 1, i.e, these objects will not be promoted to old generations, i guess is there any condition when objects will be allocated to old generations directly in G1 GC? Thanks in advance!

Excerpt of GC log:

grep "ALLOC(Old)" gc.log | wc -l

387

grep "thres" gc.log

Desired survivor size 1207959552 bytes, new threshold 15 (max 15)

Desired survivor size 1207959552 bytes, new threshold 15 (max 15)

- age   1:   37707272 bytes,   37707272 total

JDK version:

*********Update on 2020/01/31****************

It is not humongous objects,gc log will show humongous object allocation in another way, pls kindly refer to following gc log excerpt, thx!

>> grep "StartsH" gc.log | wc -l

51

>> grep "ContinuesH" gc.log | wc -l

324

>> grep "ALLOC(Old)" gc.log | wc -l

528

Reference: https://www.redhat.com/en/blog/collecting-and-reading-g1-garbage-collector-logs-part-2

Upvotes: 2

Views: 1060

Answers (1)

Eugene
Eugene

Reputation: 120858

This happens when a big Object (50% or more from a single region) is allocated. Even the source code has a comment saying that.

Just remember that arrays are Objects too, so when you are allocating a big array of primitives, you might fall into this category. That being said, you have a very recent JVM version, where these very big objects can be reclaimed as part of a young collection.

EDIT

ALLOC(OLD) does not mean that your application has started allocating objects in the old generation. It just means that this particular region, started being used during this GC cycle. here is the method declaration and here is a usage of it, in a method called G1CollectedHeap::new_gc_alloc_region - a very appropriate name IMO.

Upvotes: 2

Related Questions