Created
July 18, 2011 06:45
-
-
Save rednaxelafx/1088708 to your computer and use it in GitHub Desktop.
Counter-example of Listing 8-1 of some JVM book, using JRockit
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
$ javac -g Test.java | |
$ ~/sdk/jrmc-4.0.1-1.6.0/bin/java -version | |
java version "1.6.0_20" | |
Java(TM) SE Runtime Environment (build 1.6.0_20-b02) | |
Oracle JRockit(R) (build R28.0.1-21-133393-1.6.0_20-20100512-2126-linux-x86_64, compiled mode) | |
$ ~/sdk/jrmc-4.0.1-1.6.0/bin/java -verbose:gc Test | |
[INFO ][memory ] Running with 32 bit heap and compressed references. | |
[INFO ][memory ] GC mode: Garbage collection optimized for throughput, strategy: Generational Parallel Mark & Sweep. | |
[INFO ][memory ] Heap size: 65536KB, maximal heap size: 3145728KB, nursery size: 32768KB. | |
[INFO ][memory ] <start>-<end>: <type> <before>KB-><after>KB (<heap>KB), <time> ms, sum of pauses <pause> ms. | |
[INFO ][memory ] <start> - start time of collection (seconds since jvm start). | |
[INFO ][memory ] <type> - OC (old collection) or YC (young collection). | |
[INFO ][memory ] <end> - end time of collection (seconds since jvm start). | |
[INFO ][memory ] <before> - memory used by objects before collection (KB). | |
[INFO ][memory ] <after> - memory used by objects after collection (KB). | |
[INFO ][memory ] <heap> - size of heap after collection (KB). | |
[INFO ][memory ] <time> - total time of collection (milliseconds). | |
[INFO ][memory ] <pause> - total sum of pauses during collection (milliseconds). | |
[INFO ][memory ] Run with -Xverbose:gcpause to see individual phases. | |
[INFO ][memory ] [OC#1] 0.798-0.803: OC 436KB->65826KB (98308KB), 0.005 s, sum of pauses 3.461 ms, longest pause 3.461 ms. | |
[INFO ][memory ] [YC#1] 0.855-0.856: YC 65828KB->65900KB (98308KB), 0.002 s, sum of pauses 1.488 ms, longest pause 1.488 ms. | |
$ ~/sdk/jrmc-4.0.1-1.6.0/bin/java -XX:FullSystemGC=true -verbose:gc Test | |
[INFO ][memory ] Running with 32 bit heap and compressed references. | |
[INFO ][memory ] GC mode: Garbage collection optimized for throughput, strategy: Generational Parallel Mark & Sweep. | |
[INFO ][memory ] Heap size: 65536KB, maximal heap size: 3145728KB, nursery size: 32768KB. | |
[INFO ][memory ] <start>-<end>: <type> <before>KB-><after>KB (<heap>KB), <time> ms, sum of pauses <pause> ms. | |
[INFO ][memory ] <start> - start time of collection (seconds since jvm start). | |
[INFO ][memory ] <type> - OC (old collection) or YC (young collection). | |
[INFO ][memory ] <end> - end time of collection (seconds since jvm start). | |
[INFO ][memory ] <before> - memory used by objects before collection (KB). | |
[INFO ][memory ] <after> - memory used by objects after collection (KB). | |
[INFO ][memory ] <heap> - size of heap after collection (KB). | |
[INFO ][memory ] <time> - total time of collection (milliseconds). | |
[INFO ][memory ] <pause> - total sum of pauses during collection (milliseconds). | |
[INFO ][memory ] Run with -Xverbose:gcpause to see individual phases. | |
[INFO ][memory ] [OC#1] 0.318-0.321: OC 436KB->65826KB (98308KB), 0.003 s, sum of pauses 1.436 ms, longest pause 1.436 ms. | |
[INFO ][memory ] [OC#2] 0.373-0.379: OC 65828KB->209KB (98308KB), 0.005 s, sum of pauses 3.767 ms, longest pause 3.767 ms. | |
$ |
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
public class Test { | |
public static void main(String[] args) { | |
byte[] placeholder = new byte[64 * 1024 * 1024]; | |
System.gc(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The example in the book said this code doesn't get the byte array referenced to by
placeholder
GC'd. But here we show it can get GC'd, when using JRockit with-XX:FullSystemGC=true
.