jvisualvm jmap jstack

hpsc


grant codebase "file:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/lib/tools.jar" {permission java.security.AllPermission;};
jstatd -J-Djava.security.policy=/usr/bin/jstatd.all.policy -J-Djava.rmi.server.hostname=15.48.11.67


------------------
sampler vs profiler
Sampling means taking lots of thread dumps and analyzing stack traces. This is usually faster, does not require runtime changes in your bytecode (which may break it), but is also less accurate.

Profiling means instrumenting your classes and methods, so they "report" whenever they are run. This is more accurate, as it counts every invocation of instrumented method, not only those caught when the dump is done. However instrumentation means that the bytecode of your classes is changed, and this may break your program. Actually, for that reason, using profiling on large application servers (like JBoss, or WebLogic) often causes everything to die or hang.

-------------
jmap 就相当于jvisualvm 中的 heapdump -- jmap -histo pid > a.log
jstack 就相当于jvisualvm 中的 ThreadDump
-- jstat -gc pid 查看GC信息,如果fullGC太多的话,系统会很慢,需要修改配置

jinfo 查看jvm的信息, 最大内存等
jhat 分析heapdump文件
jconsole 也能像jvisualvm一样监控Thread和Memory的数据

jvisualvm 还多出一个功能 Profiler 监控CPU使用情况,哪些方法调用次数多,Hotspot在哪里。

jstatd是一个监控 JVM 从创建到销毁过程中资源占用情况并提供远程监控接口的 RMI


在系统出现OOM时会生成heapdump文件
添加参数
-XX:+HeapDumpOnOutOfMemoryError


heapdump 文件可以用jhat和mat(memory analysis)来分析
jhat是以html的方式展现 看的不够直观
mat 是一个eclipse插件,能从各种不同的维度来分析
jproflie 也可以做类似功能,但是其使用复杂,而且又是收费的

at命令 参数
-k keepalive 不用每次都新开http请求
-t 执行多少时间 最多5w次
ab -n 1000 -c 20 -k -t 6000 http://localhost:8085/tristanSpringMVC03/user/search

-------------------
jstatd

在java/bin下创建 一个文件 内容是
grant codebase "file:/usr/java/jdk1.7.0_51/lib/tools.jar" {permission java.security.AllPermission;};


运行
./jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=192.168.81.135
启动jstatd, 在远程就可以通过jvisualvm来监控了。

但是jvisualvm中heapdump,threaddump, profiler功能没有了。
只能Monitor Heap/Threads 趋势变化 和 Visual GC

想看heapdump信息在服务器上用jmap来收集并查看。
jmap -histo 5491 |grep tristan
83: 296 18944 com.tristan.web.po.User
1573: 1 56 com.tristan.web.service.UserService$$EnhancerByCGLIB$$a75a8f37
1579: 1 56 com.tristan.web.service.UserService$$EnhancerByCGLIB$$cde2642f
1610: 1 48 com.tristan.web.dao.UserDAO$$EnhancerByCGLIB$$d7adc653
1871: 2 32 com.tristan.web.controller.UserController
1946: 2 32 com.tristan.web.service.UserService$$FastClassByCGLIB$$49c28815
2264: 1 24 com.tristan.web.service.UserService
2343: 1 16 com.tristan.web.service.UserService$$EnhancerByCGLIB$$cde2642f$$FastClassByCGLIB$$2c604bd1
2520: 1 16 com.tristan.web.service.UserService$$EnhancerByCGLIB$$a75a8f37$$FastClassByCGLIB$$c0d4dee5
2596: 1 16 com.tristan.web.dao.UserDAO$$FastClassByCGLIB$$bde3e2cf
2711: 1 16 com.tristan.web.dao.UserDAO$$EnhancerByCGLIB$$d7adc653$$FastClassByCGLIB$$b780805e
2948: 1 16 com.tristan.web.dao.UserDAO
2966: 1 16 com.tristan.web.utils.PerformaceLog
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值