java内存分析(jmap和jhat使用)

以下介绍jdk 1.6自带的内存分析小工具的使用,非常小巧!与jprofiler不一样的效果。


举例:对java进程id为16912的进程进行分析


1、产生dump文件 c:\>jmap -dump:file=f:\yown\dump.txt 16912
Dumping heap to F:\apps\dump.txt ...
Heap dump file created



2、生成站点分析报告,便于网络访问 c:\>jhat -J-Xmx512m -port 88f:\yown\dump.txt
Reading from f:\apps\dump.txt...
Dump file created Thu Jul 26 16:31:36 CST 2012
Snapshot read, resolving...
Resolving 2194971 objects...
Chasing references, expect 438 dots.............................................
................................................................................
................................................................................
................................................................................
................................................................................
.........................................................................
Eliminating duplicate references................................................
................................................................................
................................................................................
................................................................................
................................................................................
......................................................................
Snapshot resolved.
Started HTTP server on port 88

Server is ready.


3、访问 http://localhost:88/ 这里记录了进程中所有类及实例个数(在页面最底部)

java内存分析(jmap和jhat使用)_第1张图片

很方便哦,还提供了网络访问!



你可能感兴趣的:(java,jdk,网络,server,File,工具)