JProfiler试用手记( 转 )
JProfiler试用手记所谓“工欲善其事,必先利其器”,好的工具确能起到事半工倍的作用。我用到的最多的就两个JConsole 和JProfiler 。JConsole监控系统内存变化情况,如果有内存溢出的话,垃圾回收将会呈现锯齿状。发现问题以后,使用JProfiler,在小压力(或无压力)的情况下监控对象变化,定位内存溢出原因。 JProfiler是一款Java的性能监控工具。可以查看当前应用的对象、对象引用、内存、CPU使用情况、线程、线程运行情况(阻塞、等待等),同时可以查找应用内存使用得热点,即:哪个对象占用的内存比较多;或者CPU热点,即:哪儿方法占用的较大得CPU资源。我使用的是4.3.2版本,以前试用过3**版本,不过那个bug比较多,容易死,4**版本稳定多了。 有了上面那些信息对于系统的调优会有很大帮助。这里提供有几篇文章供参考:获取、介绍,简单入门,使用JProfiler解决实际问题。这几篇文章基本介绍了常见东西了,下面说点心得。
Windows客户端的JProfiler远程监控Linux上的Tomcat 2.JProfiler软件下载地址 http://www.ej-technologies.com/ 3.客户端 JProfiler 安装 略 4.服务器端 JProfiler 安装: # cd /opt/jprofiler 注意,这里的 -c 意思是用字符方式来安装,如果机器上没有 X 则加上该参数. 5.客户端连接配置 Integration type: [Generic application]
Selected JVM: Sun 1.5.0 (hotspot) Startup mode: Wait for JProfiler GUI (1) Please insert -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar into the start command of your remote application right after the java command. (2) Please add /opt/jprofiler4/bin/linux-x86 to the environment variable LD_LIBRARY_PATH. A remote session named Remote application on 192.168.40.15 will be created that connects to a running instance of the remote application that is started with the modified start command.
JPROFILER_HOME=/opt/jprofiler4/bin/linux-x86
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JPROFILER_HOME
CATALINA_OPTS="$CATALINA_OPTS -Xms128m -Xmx128m $JPDA_OPTS -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar"
JProfiler> Protocol version 23
JProfiler> Using JVMTI JProfiler> 32-bit library JProfiler> Listening on port: 8849. JProfiler> Native library initialized JProfiler> Waiting for a connection from the JProfiler GUI 8.启动客户端软件 9.The log of tomcat which is $CATALINA_HOME/logs/catalina.out will show: JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time JProfiler> CPU profiling enabled JProfiler> Hotspot compiler enabled JProfiler> Starting org/apache/catalina/startup/Bootstrap 10.当中断JProfiler连接时 JProfiler> Disconnected. Waiting for reconnection.
JProfiler> Listening on port: 8849. |
原文出处:http://hi.baidu.com/xuwanbest/blog/item/605f9f3335f05e46ac4b5f07.html 。