Skip to content

Instantly share code, notes, and snippets.

@codedoneteam
Last active May 30, 2021 20:40
Show Gist options
  • Save codedoneteam/fe5e5d5e6e19035f54e17eeb872516ba to your computer and use it in GitHub Desktop.
Save codedoneteam/fe5e5d5e6e19035f54e17eeb872516ba to your computer and use it in GitHub Desktop.
Proffiling
# jstack
jstack -l <PID> > threads.txt
Generate Heap dump on EOM error
-XX:+HeapDumpOnOutOfMemoryError
#Heap
jmap -dump:file=DumpFile.dump <PID>
jhat DumpFile.dump
Eclipse MAT -> dominator tree
## Display the class name of all ClassLoaders
select classof(cl).name from instanceof java.lang.ClassLoader cl
Query an int array with a length greater than or equal to 256
select a from [I a where a.length >= 256
#async
java -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:+UseCountedLoopSafepoints -jar <JAR.FILE>
./profiler.sh -d 30 -f /tmp/flamegraph.html <PID>
#Linux process memory
pmap -x <PID>
#Native memoty tracking
java -XX:NativeMemoryTracking=summary -jar <JAR.FILE>
jcmd <PID> VM.native_memory
#Classloader statistic
jcmd <PID> VM.native_memory
#Class statistic
jcmd <PID> GC.class_stats
#LTAB allocation
sudo apt-get install openjdk-8-dbg
./profiler.sh -e alloc -d 10 -f /tmp/flamegraph.html <PID>
#Run application with eadger memory allocation
java -Xms=10G -Xmx=10Gb -XX:+AlwaysPreTouch -jar <JAR.FILE>
#Profile syscalls
profiler.sh -d 10 -e syscall:open <PID>
#Lock
profiler.sh -d 10 -e lock <PID>
#Start JFR
jcmd <PID> JFR.start duration=100s filename=flight.jfr
java -XX:StartFlightRecording=settings=profile.jfc -jar <JAR.FILE>
#Linux show process open files
ls -l /proc/<PID>/fd
#Show process listen sockets
netstat -tulpn | grep <PID>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment