Skip to content

Instantly share code, notes, and snippets.

Avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / gist:1066883
Created July 6, 2011 09:11
how -Xmn and -XX:MaxNewSize/-XX:NewSize interact (JDK6u25)
View gist:1066883
$ java -XX:+PrintFlagsFinal -Xmn200m -Xmn300m -Xmn400m | grep 'NewSize'
uintx MaxNewSize := 419430400 {product}
uintx NewSize := 419430400 {product}
uintx NewSizeThreadIncrease = 5320 {pd product}
$ java -XX:+PrintFlagsFinal -Xmn200m -Xmn300m -Xmn400m -XX:MaxNewSize=100m | grep 'NewSize'
uintx MaxNewSize := 419430400 {product}
uintx NewSize := 419430400 {product}
uintx NewSizeThreadIncrease = 5320 {pd product}
$ java -XX:+PrintFlagsFinal -Xmn200m -Xmn300m -Xmn400m -XX:MaxNewSize=100m -XX:NewSize=100m | grep 'NewSize'
uintx MaxNewSize := 104857600 {product}
View LoopTest.java
package nerdscentral;
public class LoopTest {
static long count = 0;
static class ReturnDispatch extends RuntimeException{
@Override
public Throwable fillInStackTrace(){
View LoopTest.java
package nerdscentral;
public class LoopTest {
static long count = 0;
static class ReturnDispatch extends RuntimeException{
@Override
public Throwable fillInStackTrace(){
@rednaxelafx
rednaxelafx / command prompt
Created July 17, 2011 08:51
There's probably a bug in current version of HotSpot's SA on amd64 on decoding stack traces.
View command prompt
rednaxelafx@fx-laptop:~$ jps
2477 GroovyStarter
2576 Jps
rednaxelafx@fx-laptop:~$ pgrep java
2477
rednaxelafx@fx-laptop:~$ echo $JAVA_HOME
/home/rednaxelafx/sdk/jdk1.6.0_25
rednaxelafx@fx-laptop:~$ sudo su
root@fx-laptop:/home/rednaxelafx# pgrep java
2477
@rednaxelafx
rednaxelafx / Test.java
Created July 18, 2011 06:45
Counter-example of Listing 8-1 of some JVM book, using JRockit
View Test.java
public class Test {
public static void main(String[] args) {
byte[] placeholder = new byte[64 * 1024 * 1024];
System.gc();
}
}
@rednaxelafx
rednaxelafx / groovy shell
Created July 18, 2011 23:09
invoker and exactInvoker
View groovy shell
$ groovysh
Groovy Shell (1.7.5, JVM: 1.7.0-ea)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> import java.lang.invoke.*
===> [import java.lang.invoke.*]
groovy:000> mt = MethodType.methodType(String, String)
===> (String)String
groovy:000> MethodHandles.exactInvoker(mt)
===> MethodHandle(MethodHandle,String)String
@rednaxelafx
rednaxelafx / command prompt
Created July 23, 2011 13:07
example that shows the difference in the strategy used to implement the string pool in JVMs. watch for the effect of PermGen removal in newer HotSpot
View command prompt
$ use6u25
$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
$ groovysh
Groovy Shell (1.7.5, JVM: 1.6.0_25)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> s = new String([(byte) 'a', (byte) 'b'] as byte[])
@rednaxelafx
rednaxelafx / command prompt
Created July 26, 2011 08:19
JMX old gen GC count is incremented by 2 at a System.gc() in CMS in JDK6u23-6u26, while it incremented by 1 in 6u22 and earlier.
View command prompt
D:\sdk\groovy-1.7.6\bin>set JAVA_OPTS=-XX:+UseConcMarkSweepGC
D:\sdk\groovy-1.7.6\bin>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
D:\sdk\groovy-1.7.6\bin>groovysh
Groovy Shell (1.7.6, JVM: 1.6.0_26)
Type 'help' or '\h' for help.
@rednaxelafx
rednaxelafx / groovysh
Created August 3, 2011 11:35
bootstrapping the CMS stats may fail if allocation rate is too high. then the CMS stats would still be invalid after the first concurrent GC cycle. JDK6u25/HS20-b11
View groovysh
$ export JAVA_OPTS='-XX:+PrintGCDetails -XX:+UseConcMarkSweepGC'
$ groovysh
[GC [ParNew: 17024K->2112K(19136K), 0.0320220 secs] 17024K->2503K(83008K), 0.0323140 secs] [Times: user=0.04 sys=0.00, real=0.03 secs]
[GC [ParNew: 19136K->2112K(19136K), 0.1166830 secs] 19527K->6890K(83008K), 0.1167640 secs] [Times: user=0.26 sys=0.02, real=0.12 secs]
Groovy Shell (1.7.7, JVM: 1.6.0_25)
Type 'help' or '\h' for help.
-----------------------------------------------------------------------------------------------------------------
groovy:000> list = []
===> []
groovy:000> 1000000.times { list << [:] }
@rednaxelafx
rednaxelafx / WrongInline.java
Created August 9, 2011 09:44
failed attempt to add Phi::exact_type() to HotSpot C1
View WrongInline.java
import java.util.*;
/*
*/
public class WrongInline {
public static void test(String[] args) {
List<?> list;
if (args.length % 2 == 0) {
list = new ArrayList<String>(); // list1
} else {