Skip to content
Advertisement

Where is the “age threshold” for the referenced object stored in Garbage Collection process stored?

I am trying to understand how GC works and have been reading https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

Garbage Collection Process, point #6 says,

“After a minor GC, when aged objects reach a certain age threshold (8 in this example) they are promoted from young generation to old generation.”

I am trying to understand where the “age threshold” for the referenced object stored?

Advertisement

Answer

This information is stored in one of the two headers that any java Object has. The information of how it is stored can be read from the comments under the source code.

You can even track those bits and see how they change, from promotion to promotion, using the awesome JOL library. See this, as an example.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement