Difference between revisions of "Java"

From Vague Hope Wiki
Jump to: navigation, search
(Profiling)
(Profiling)
Line 4: Line 4:
  
 
* http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html
 
* http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html
 +
* http://www.brendangregg.com/blog/2014-06-09/java-cpu-sampling-using-hprof.html
 +
* https://github.com/jnorris/conf/blob/master/bin/hprof#L113
  
 
== OpenJDK Heapdump ==
 
== OpenJDK Heapdump ==

Revision as of 07:20, 10 March 2015

Profiling

-Xrunhprof:cpu=samples,file=/tmp/app-profile.txt -jar foo.jar

OpenJDK Heapdump

sudo yum install java-1.6.0-openjdk-devel
sudo jmap -F -J-d64 -dump:live,format=b,file=/root/heap.bin 2232
sudo jstack -F 2232 > /root/stacks.txt
sudo -u tomcat jmap -J-d64 -dump:format=b,file=/tmp/heap.bin 1384

Remote Debug Tomcat6

In /usr/sbin/tomcat6:

-Xdebug -Xrunjdwp:transport=dt_socket,address=62277,server=y,suspend=n

GC

sudo jmap -heap <pid>
java \
  -Xms300m \
  -Xmx600m \
  -verbose:gc \
  -XX:MaxGCPauseMillis=20 \
  -XX:+UseConcMarkSweepGC \
  -XX:+CMSIncrementalMode \
  -XX:+CMSIncrementalPacing \
java \
  -verbose:gc \
  -XX:+PrintGCDetails \
  -XX:MaxGCPauseMillis=20 \
  -XX:MaxGCMinorPauseMillis=10 \
  -XX:GCTimeRatio=200 \
  -XX:+UseSerialGC \
  -Xms140m -Xmx140m \