The long-lived objects of "In-depth Understanding of Java Virtual Machine" will enter the old age test results (-XX:MaxTenuringThreshold=15 does not take effect)

When reading the content of the entry of long-lived objects into the old generation in "In-depth Understanding of Java Virtual Machine", I ran the code in the book and the results are as follows (running environment: jdk1.8.0_172):

①When -XX:MaxTenuringThreshold=1, the running result is consistent with the description in the book, and the allocation1 object enters the old age when the second GC occurs.

[GC (Allocation Failure) [DefNew
Desired survivor size 524288 bytes, new threshold 1 (max 1)
- age   1:     790240 bytes,     790240 total
: 5335K->771K(9216K), 0.0031656 secs] 5335K->4867K(19456K), 0.0032127 secs] [Times: user=0.02 sys=0.00, real=0.00 secs] 
[GC (Allocation Failure) [DefNew
Desired survivor size 524288 bytes, new threshold 1 (max 1)
: 4867K->0K(9216K), 0.0008847 secs] 8963K->4866K(19456K), 0.0009065 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 def new generation   total 9216K, used 4178K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  eden space 8192K,  51% used [0x00000000fec00000, 0x00000000ff014930, 0x00000000ff400000)
  from space 1024K,   0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
  to   space 1024K,   0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000)
 tenured generation   total 10240K, used 4866K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
   the space 10240K,  47% used [0x00000000ff600000, 0x00000000ffac0b70, 0x00000000ffac0c00, 0x0000000100000000)
 Metaspace       used 2620K, capacity 4486K, committed 4864K, reserved 1056768K
  class space    used 280K, capacity 386K, committed 512K, reserved 1048576K

②When -XX:MaxTenuringThreshold=15, the running result deviates from the description in the book, and the allocation1 object also enters the old age when the second GC occurs.

[GC (Allocation Failure) [DefNew
Desired survivor size 524288 bytes, new threshold 1 (max 15)
- age   1:     790240 bytes,     790240 total
: 5335K->771K(9216K), 0.0028299 secs] 5335K->4867K(19456K), 0.0028776 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[GC (Allocation Failure) [DefNew
Desired survivor size 524288 bytes, new threshold 15 (max 15)
: 4867K->0K(9216K), 0.0008606 secs] 8963K->4866K(19456K), 0.0008757 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 def new generation   total 9216K, used 4178K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  eden space 8192K,  51% used [0x00000000fec00000, 0x00000000ff014930, 0x00000000ff400000)
  from space 1024K,   0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
  to   space 1024K,   0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000)
 tenured generation   total 10240K, used 4866K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
   the space 10240K,  47% used [0x00000000ff600000, 0x00000000ffac0b70, 0x00000000ffac0c00, 0x0000000100000000)
 Metaspace       used 2620K, capacity 4486K, committed 4864K, reserved 1056768K
  class space    used 280K, capacity 386K, committed 512K, reserved 1048576K

In the above running results, new threshold 1 (max 15) indicates that the threshold value calculated by the virtual machine itself is 1, and the maximum is 15. When -XX:MaxTenuringThreshold=15 in the book, the first red mark above is the new threshold 15 (max 15). When running in the jdk 1.6.0_37 environment, you will see the same results as the book. So guess it may be the latest version of the virtual machine has changed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325906337&siteId=291194637