使用jprofiler查看内存泄漏

使用jprofiler查看tomcat程序内存是否有泄漏的方法:

1。 首先使用jmeter构建压力测试脚本,比如10个用户循环执行100次。

2。 对于tomcat应用程序,可以通过jprofiler生成startup_jprofiler.sh脚本。其脚本就是加入如下环境变量:

# The following lines have been added by the

# application server integration wizard of JProfiler

LD_LIBRARY_PATH="/home/fishyych/tools/jprofiler5/bin/linux-x86:$LD_LIBRARY_PATH"

export LD_LIBRARY_PATH

CATALINA_OPTS="-agentlib:jprofilerti=port=8849  -Xbootclasspath/a:/home/fishyych/tools/jprofiler5/bin/agent.jar $CATALINA_OPTS"

export CATALINA_OPTS

# end of modifications

 我们也可以把上面的语句加到自己的启动脚本当中。

3。启动tomcat以及jprofiler。

4。运行一轮压力测试。

5。jprofiler执行GC, 等内存稳定以后,执行一次mark。

6。重新运行一轮压力测试。

7。jprofiler执行GC。这时差别的内存会标示出来。如果重复上面的流程发现这个新增长出来的内存不断增加,就说明发生了内存泄漏。

 

你可能感兴趣的:(tomcat,linux,脚本)