sun jdk 下如何生成heapdump文件_Tomcat, WebLogic及J2EE讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Tomcat, WebLogic及J2EE讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 4943 | 回复: 0   主题: sun jdk 下如何生成heapdump文件        下一篇 
John
注册用户
等级:大元帅
经验:90444
发帖:136
精华:2
注册:2011-7-21
状态:离线
发送短消息息给John 加好友    发送短消息息给John 发消息
发表于: IP:您无权察看 2011-8-9 10:33:19 | [全部帖] [楼主帖] 楼主

环境sunjdk + tomcat

tomcat启动时增加 HeapDumpOnOutOfMemoryError Option

此参数需要Java SE release 5.0 update 7 或以上支持

设置示例: set JAVA_OPTS=%JAVA_OPTS% -server -Xms512m -Xmx800m -XX:PermSize=64M -XX:MaxPermSize=128m -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError

测试内存溢出时可以把-Xms和-Xmx等的值相应调低即可.

文件默认产生在tomcat/bin目录下

如增加HeapDumpOnCtrlBreak Option就可以通过ctrl+break或收到SIGQUIT生成heapdump文件

此参数需要Java SE release 5.0 update 14 或以上支持

设置示例: set JAVA_OPTS=%JAVA_OPTS% -server -Xms512m -Xmx800m -XX:PermSize=64M -XX:MaxPermSize=128m -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpOnCtrlBreak

参数介绍:

HeapDumpOnOutOfMemoryError Option
The -XX:+HeapDumpOnOutOfMemoryError command-line option was introduced in Java SE release
5.0 update 7. This option tells the HotSpot VM to generate a heap dump when the first thread throws a
java.lang.OutOfMemoryError because the Java heap or the permanent generation is full. There is
no overhead in running with this option, and so it can be useful for production systems where
OutOfMemoryError takes a long time to surface.
The heap dump is in HPROF binary format, and so it can be anaylzed by any tool that can import this
format, for example the Heap Analysis Tool (HAT).
By default the heap dump is created in a file called java_pid<pid>.hprof in the working directory
of the VM, where <pid> is the process ID. You can specify an alternative file name or directory with
the -XX:HeapDumpPath= option. For example, -XX:HeapDumpPath=/disk2/dumps will cause the
heap dump to be generated in the /disk2/dumps directory.
HeapDumpOnCtrlBreak Option
The -XX:+HeapDumpOnCtrlBreak command-line option was introduced in Java SE release 5.0 update 14. This option tells the HotSpot VM to generate a heap dump when a Ctrl-Break or SIGQUIT signal
is received. This provides a way to trigger a heap dump on demand.
The heap dump is in HPROF binary format, and so it can be anaylzed by any tool that can import this
format, for example the Heap Analysis Tool (HAT). The heap dump contains only live objects.
By default the heap dump is created in a file called java_pid<pid>.hprof.<yyyymmdd>.<hhmmss>
in the working directory of the VM, where <pid> is the process ID, and <yyyymmdd>.<hhmmss> is the
approximate time when the heap dump was generated.
You can specify an alternative file name or directory with the -XX:HeapDumpPath= option. For
example, -XX:HeapDumpPath=/disk2/dumps will cause the heap dump to be generated in the
/disk2/dumps directory.
If both the -XX:+HeapDumpOnCtrlBreak and -XX:+PrintClassHistogram options are enabled, the
heap dump and the heap histogram are obtained from the same heap snapshot.


详见JavaTM 2 Platform, Standard Edition 5.0 Troubleshooting and Diagnostic Guide




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论