Created
July 17, 2012 07:35
-
-
Save stingh711/3127831 to your computer and use it in GitHub Desktop.
Try to make JVM only do full GC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OnlyFullGc { | |
private static final int _1M = 1024 * 1024; | |
//java -verbose:gc -XX:+PrintGCDetails -XX:PretenureSizeThreshold=3145728 -Xms20M -Xmx20M -Xmn10M OnlyFullGc | |
//1 | |
//2 | |
//[GC [Tenured: 9216K->4237K(10240K), 0.0110910 secs] 9543K->4237K(19456K), [Perm : 91K->91K(12288K)], 0.0113940 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] | |
//3 | |
//Heap | |
//def new generation total 9216K, used 491K [0x8e510000, 0x8ef10000, 0x8ef10000) | |
//eden space 8192K, 6% used [0x8e510000, 0x8e58af00, 0x8ed10000) | |
//from space 1024K, 0% used [0x8ed10000, 0x8ed10000, 0x8ee10000) | |
//to space 1024K, 0% used [0x8ee10000, 0x8ee10000, 0x8ef10000) | |
//tenured generation total 10240K, used 9357K [0x8ef10000, 0x8f910000, 0x8f910000) | |
//the space 10240K, 91% used [0x8ef10000, 0x8f833468, 0x8f833600, 0x8f910000) | |
//compacting perm gen total 12288K, used 91K [0x8f910000, 0x90510000, 0x93910000) | |
//the space 12288K, 0% used [0x8f910000, 0x8f926eb8, 0x8f927000, 0x90510000) | |
//ro space 10240K, 60% used [0x93910000, 0x93f1dba0, 0x93f1dc00, 0x94310000) | |
//rw space 12288K, 61% used [0x94310000, 0x94a72ed0, 0x94a73000, 0x94f10000) | |
public static void main(String[] args) { | |
byte[] a0, a1; | |
a0 = new byte[5 * _1M]; | |
System.out.println(1); | |
a1 = new byte[4 * _1M]; | |
System.out.println(2); | |
a0 = null; | |
a0 = new byte[5 * _1M]; | |
System.out.println(3); | |
} | |
} |
second version works
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
failed..