[arthas@1701]$help NAME DESCRIPTION help Display Arthas Help keymap Display all the available keymap for the specified connection. sc Search all the classes loaded by JVM sm Search the method of classes loaded by JVM classloader Show classloader info jad Decompile class getstatic Show the static field of a class monitor Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc. stack Display the stack trace for the specified class and method thread Display thread info, thread stack trace Trace the execution time of specified method invocation. watch Display the input/output parameter, return object, and thrown exception of specified method invocation tt Time Tunnel jvm Display the target JVM information ognl Execute ognl expression. mc Memory compiler, compiles java files into bytecode and class files in memory. redefine Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...) dashboard Overview of target jvm's thread, memory, gc, vm, tomcat info. dump Dump class byte array from JVM heapdump Heap dump options View and change various Arthas options cls Clear the screen reset Reset all the enhanced classes version Display Arthas version shutdown Shutdown Arthas server and exit the console stop Stop/Shutdown Arthas server and exit the console. Alias for shutdown. session Display current session information sysprop Display, and change the system properties. sysenv Display the system env. vmoption Display, and update the vm diagnostic options. logger Print logger info, and update the logger level history Display command history cat Concatenate and print files pwd Return working directory name mbean Display the mbean information grep grep command for pipes. profiler Async Profiler. https://github.com/jvm-profiling-tools/async-profiler
/** * 堆溢出: java对象在堆中分配内存 * * VM options: -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError * * 执行结果: * * 分配次数:1 * 分配次数:2 * 分配次数:3 * java.lang.OutOfMemoryError: Java heap space * Dumping heap to java_pid17426.hprof ... * Heap dump file created [17431809 bytes in 0.026 secs] * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space * at com.example.demojava.demo.HeapOOm.main(HeapOOm.java:15) */ publicclassHeapOOm{
publicstaticvoidmain(String[] args){ List<byte[]> list = new ArrayList<>(); int i=0; while(true){ list.add(newbyte[5*1024*1024]); System.out.println("分配次数:"+(++i)); } } }