Automatic object advancement to the Old Generation

An object can be promoted from Young Generation to Old Generation when it reaches the Turing threshold or when the "TO" Survival Space is filled when it is being transferred.

Therefore, my question is: to improve performance, if I know that my object will be used often (link), it is possible to automatically / manually declare an object in the old / permanent generation so as not to announce it in Eden, would delay the need for Small garbage collection, putting aside thereby stopping the world and improving application performance?

+4
source share
2 answers

Generally:

No - not for a specific individual object.

More details:

The rougly distribution is as follows:

  • Use local stream allocation buffer (TLAB) if tlab_top + size <= tlab_end. This is the fastest way. Selection is just an increment of the pointer tlab_top.
  • If the TLAB is nearly full, create a new TLAB in the Eden space and try again in the new TLAB.
  • If the remaining TLAB space is insufficient, but it is still large for failure, try allocating the object directly in the Eden space. The distribution in the Eden space must be performed using an atomic operation, since the Eden is shared between all flows.
  • If the distribution in the Eden space fails ( eden_top + size > eden_end), usually a small collection occurs.
  • Eden Young GC, .

"Hack":

:

XX:PretenureSizeThreshold=size

0, . , , .

:

: GC. : GC, GC.

, GC , "" , .

Java:

Java-, :

java -XX:+PrintVMOptions -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+PrintFlagsFinal  -version

, .

:

, , , Java 9 GC- (G1) GC , - ( ).

:

: ,

+3

, ( ), . , , (, - ), JVM:

-XX:InitialTenuringThreshold=7: GC . - , , .

-XX:MaxTenuringThreshold=n: GC. - 15. - 15 4 CMS.

: http://www.oracle.com/technetwork/articles/java/vmoptions-jsp-140102.html

, . GC GC ( 250- JVM, ).

0

Source: https://habr.com/ru/post/1629710/


All Articles