本站首页    管理页面    写新日志    退出


«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告

戒除浮躁,读好书,交益友


我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:邢红瑞的blog
日志总数:523
评论数量:1142
留言数量:0
访问次数:9692241
建立时间:2004年12月20日




[java语言]Quick Troubleshooting Tips on Solaris OS and Linux for Java SE 6
文章收藏,  网上资源,  软件技术,  电脑与网络

邢红瑞 发表于 2008/7/29 11:58:49

This "Quick Start Guide" gives you some quick tips for troubleshooting. The subsections list some typical functions that can help you in troubleshooting, including one or more ways to get the information or perform the action. These tips are organized as follows: Hung, Deadlocked, or Looping Process Post-mortem Diagnostics, Memory Leaks MonitoringActions on a Remote Debug ServerOther Functions Hung, Deadlocked, or Looping Process Print thread stack for all Java threads: Control-\ kill -QUIT pid jstack pid (or jstack -F pid if jstack pid does not respond) Detect deadlocks: Request deadlock detection: JConsole tool, Threads tab Print information on deadlocked threads: Control-\ Print list of concurrent locks owned by each thread: -XX:+PrintConcurrentLocks set, then Control-\ Print lock information for a process: jstack -l pid Get a heap histogram for a process: Start Java process with -XX:+PrintClassHistogram, then Control-\ jmap -histo pid (with -F option if pid does not respond) Dump Java heap for a process in binary format to file: jmap -dump:format=b,file=filename pid (with -F option if pid does not respond) Print shared object mappings for a process: jmap pid Print heap summary for a process: Control-\ jmap -heap pid Print finalization information for a process: jmap -finalizerinfo pid Attach the command-line debugger to a process: jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=pid Post-mortem Diagnostics, Memory Leaks Examine the fatal error log file. Default file name is hs_err_pidpid.log in the working-directory. Create a heap dump: Start the application with HPROF enabled: java -agentlib:hprof=file=file,format=b application; then Control-\ Start the application with HPROF enabled: java -agentlib:hprof=heap=dump application JConsole tool, MBeans tab Start VM with -XX:+HeapDumpOnOutOfMemoryError; if OutOfMemoryError is thrown, VM generates a heap dump. Browse Java heap dump: jhat heap-dump-file Dump Java heap from core file in binary format to a file: jmap -dump:format=b,file=filename corefile Get a heap histogram for a process: Start Java process with -XX:+PrintClassHistogram, then Control-\ jmap -histo pid (with -F option if pid does not respond) Get a heap histogram from a core file: jmap -histo corefile Print shared object mappings from a core file: jmap corefile Print heap summary from a core file: jmap -heap corefile Print finalization information from a core file: jmap -finalizerinfo corefile Print Java configuration information from a core file: jinfo corefile Print thread trace from a core file: jstack corefile Print lock information from a core file: jstack -l corefile Attach the command-line debugger to a core file on the same machine: jdb -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:javaExecutable=path,core=corefile Attach the command-line debugger to a core file on a different machine: On the machine with the core file: jsadebugd path corefile and on the machine with the debugger: jdb -connect sun.jvm.hotspot.jdi.SADebugServerAttachingConnector:debugServerName=machine libumem can be used to debug memory leaks. Monitoring Note: The vmID argument for the jstat command is the virtual machine identifier. See the jstat man page for a detailed explanation. Print statistics on the class loader: jstat -class vmID Print statistics on the compiler: Compiler behavior: jstat -compiler vmID Compilation method statistics: jstat -printcompilation vmID Print statistics on garbage collection: Summary of statistics: jstat -gcutil vmID Summary of statistics, with causes: jstat -gccause vmID Behavior of the gc heap: jstat -gc vmID Capacities of all the generations: jstat -gccapacity vmID Behavior of the new generation: jstat -gcnew vmID Capacity of the new generation: jstat -gcnewcapacity vmID Behavior of the old and permanent generations: jstat -gcold vmID Capacity of the old generation: jstat -gcoldcapacity vmID Capacity of the permanent generation: jstat -gcpermcapacity vmID Monitor objects awaiting finalization: JConsole tool, VM Summary tab jmap -finalizerinfo pid getObjectPendingFinalizationCount method in java.lang.management.MemoryMXBean class Monitor memory: Heap allocation profiles via HPROF: java -agentlib:hprof=heap=sites JConsole tool, Memory tab Control-\ prints generation information. Monitor CPU usage: By thread stack: java -agentlib:hprof=cpu=samples application By method: java -agentlib:hprof=cpu=times application JConsole tool, Overview and VM Summary tabs Monitor thread activity: JConsole tool, Threads tab Monitor class activity: JConsole tool, Classes tab Actions on a Remote Debug Server First, attach the debug daemon jsadebugd, then execute the command: Dump Java heap in binary format to a file: jmap -dump:format=b,file=filename hostID Print shared object mappings: jmap hostID Print heap summary : jmap -heap hostID Print finalization information : jmap -finalizerinfo hostID Print lock information : jstack -l hostID Print thread trace : jstack hostID Print Java configuration information: jinfo hostID Other Functions Interface with the instrumented Java virtual machines: Monitor for the creation and termination of instrumented VMs: jstatd daemon List the instrumented VMs: jps Provide interface between remote monitoring tools and local VMs: jstatd daemon Request garbage collection: JConsole tool, Memory tab Print Java configuration information from a running process: jinfo pid Dynamically set, unset, or change the value of certain Java VM flags for a process: jinfo -flag flag Print command-line flags passed to the VM: jinfo -flags Print Java system properties: jinfo -sysprops Pass a Java VM flag to the virtual machine: jconsole -Jflag ... jhat -Jflag ... jmap -Jflag ... Print statistics of permanent generation of Java heap, by class loader: jmap -permstat Report on monitor contention. java -agentlib:hprof=monitor=y application Evaluate or execute a script in interactive or batch mode: jrunscript Interface dynamically with an MBean, via JConsole tool, MBean tab: Show tree structure. Set an attribute value. Invoke an operation. Subscribe to notification. Run interactive command-line debugger: Launch a new VM for the class: jdb class Attach debugger to a running VM: jdb -attach address


阅读全文(3896) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.063 second(s), page refreshed 144752227 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号