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 , - ( ).
:
: ,