Linux command
jmap 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Print class loader statistics
jmap -clstats [pid]
Dump heap to file
jmap -dump:format=b,file=[heap.hprof] [pid]
Dump live objects only
jmap -dump:live,format=b,file=[heap.hprof] [pid]
Histogram of objects
jmap -histo [pid]
Live objects histogram
jmap -histo:live [pid]
说明
jmap prints memory-related statistics for Java processes. It generates heap dumps, object histograms, and class loader statistics. The tool is essential for memory analysis and leak detection. Heap dumps can be analyzed with tools like Eclipse MAT or VisualVM.
参数
- -clstats _pid_
- Print class loader statistics of the Java heap.
- -finalizerinfo _pid_
- Print information on objects awaiting finalization.
- -histo:live
- Print histogram of the Java object heap. With :live, counts only live objects.
- -dump:_options_
- Dump the Java heap. Sub-options:
- :live
- Only live objects.
- :format=b
- Binary hprof format.
- :file=_FILE_
- Output file path.
FAQ
What is the jmap command used for?
jmap prints memory-related statistics for Java processes. It generates heap dumps, object histograms, and class loader statistics. The tool is essential for memory analysis and leak detection. Heap dumps can be analyzed with tools like Eclipse MAT or VisualVM.
How do I run a basic jmap example?
Run `jmap -clstats [pid]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -clstats _pid_ do in jmap?
Print class loader statistics of the Java heap.