工具命令
java
java [options] -jar filename [args]
options
# -Xmx : Sets the maximum size (in byes) of the memory allocation pool,The -Xmx option is equivalent to -XX:MaxHeapSize.
java -Xmx80M
# -Xmx : Sets the minimum and the initial size (in bytes) of the heap,the -XX:InitalHeapSize option can also be used to set the initial heap size
java -Xms80M
#Sets a system property value
java -Dproperty=value
args
The arguments passed to the main() method separated by spaces
javaw
launch a Java application without a console window(Windows Only),The javaw
command is identical to java, except that with javaw there’s no associated console window
jps
list the instrumented JVMs on the target system,可用于获取每个java进程id
options:
- -l displays the full package name for the application’s main class or the full path name to the application’s JAR file.
jsp -l
jstack
print Java stack traces of Java threads for a specified Java process
options:
- -l long listing. Prints additional information about locks
- -e extended listing. Prints additional information about threads,allocated字段为每个线程被分配的内存量
- -? -h --help -help to print this help message
jstack -l -e <pid>
名词解释
heap
The Java Virtual Machine has a heap that is shared among all Java Virtual Machine
threads. The heap is the run-time data area from which memory for all class
instances and arrays is allocated.
The heap is created on virtual machine start-up. Heap storage for objects is
reclaimed by an automatic storage management system (known as a garbage
collector); objects are never explicitly deallocated.