Skip to content

Instantly share code, notes, and snippets.

@stingh711
Created July 17, 2012 06:20
Show Gist options
  • Save stingh711/3127566 to your computer and use it in GitHub Desktop.
Save stingh711/3127566 to your computer and use it in GitHub Desktop.
Test MaxTenuringThreshold
private static final int _1M = 1024 * 1024;
/**
* Test with -verbose:gc -XX:+PrintGCDetails -Xms20M -Xmx20M -Xmn10M -XX:MaxTenuringThreshold=1
*/
public static void testMaxTenuringThreshold() {
byte[] a1, a2, a3;
a1 = new byte[_1M / 4];
System.out.println(1);
a2 = new byte[4 * _1M];
System.out.println(2);
a3 = new byte[4 * _1M];
a3 = null;
System.out.println(3);
a3 = new byte[4 * _1M];
System.out.println(4);
}
@stingh711
Copy link
Author

The result is:

1
2
[GC [DefNew: 4679K->397K(9216K), 0.0086400 secs] 4679K->4493K(19456K), 0.0087510 secs] [Times: user=0.00 sys=0.01, real=0.01 secs]
3
[GC [DefNew: 4744K->0K(9216K), 0.0014650 secs] 8840K->4486K(19456K), 0.0015510 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
4
Heap
def new generation total 9216K, used 4318K [0x8e510000, 0x8ef10000, 0x8ef10000)
eden space 8192K, 52% used [0x8e510000, 0x8e947870, 0x8ed10000)
from space 1024K, 0% used [0x8ed10000, 0x8ed10088, 0x8ee10000)
to space 1024K, 0% used [0x8ee10000, 0x8ee10000, 0x8ef10000)
tenured generation total 10240K, used 4486K [0x8ef10000, 0x8f910000, 0x8f910000)
the space 10240K, 43% used [0x8ef10000, 0x8f371ac8, 0x8f371c00, 0x8f910000)
compacting perm gen total 12288K, used 91K [0x8f910000, 0x90510000, 0x93910000)
the space 12288K, 0% used [0x8f910000, 0x8f926ec0, 0x8f927000, 0x90510000)
ro space 10240K, 60% used [0x93910000, 0x93f1dba0, 0x93f1dc00, 0x94310000)
rw space 12288K, 61% used [0x94310000, 0x94a72ed0, 0x94a73000, 0x94f10000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment