一:异常项目构建

1.通过while死循环构造异常常见:

package com.huawei.jvm;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; /**
* This is Description
*
* @author 王明飞
* @date 2018/08/31
*/ @Controller
public class Test { @RequestMapping("/hello")
public String hello()
{
return "hello";
} @RequestMapping("/jvm01")
public void jvm01()
{
while (true)
{
}
}
}

二:项目部署到linux服务器上

1.可通过war包放到webapp目录下;

2.启动tomcat自动解压。

3.关闭tomcat;

4.删除webapp目录下的war包

5.启动tomcat;

三:linux 服务器top命令查看

终端观察下图中的三处变化

访问前:top命令状态

curl使用后:

可以看到cpu使用达到了99.7%

四: 使用jstack命令

[root@localhost ~]# jstack 16350 >16350.txt
[root@localhost ~]# ll
总用量 179304
-rw-r--r--. 1 root root 12687 8月 2 08:19 16350.txt
-rw-------. 1 root root 1096 7月 22 00:54 anaconda-ks.cfg
drwxr-xr-x. 9 root root 4096 7月 24 23:12 apache-tomcat-7.0.47
-rw-r--r--. 1 root root 8234674 9月 11 2015 apache-tomcat-7.0.47.tar.gz
-rw-r--r--. 1 root root 14558 8月 2 04:33 a.txt
drwxr-xr-x. 3 root root 4096 7月 22 03:44 IK Analyzer 2012FF_hf1
-rw-r--r--. 1 root root 8017 7月 22 00:54 install.log
-rw-r--r--. 1 root root 3384 7月 22 00:53 install.log.syslog
-rw-r--r--. 1 root root 7586984 9月 1 2018 jvm-test01-1.0-SNAPSHOT.war
drwxr-xr-x. 8 root root 4096 7月 22 02:03 solr-4.10.3
-rw-r--r--. 1 root root 150010621 9月 11 2015 solr-4.10.3.tgz.tgz
drwxr-xr-x. 10 1000 1000 4096 2月 20 2014 zookeeper-3.4.6
-rwxrwxrwx. 1 root root 17699306 5月 28 21:14 zookeeper-3.4.6.tar.gz

五:按住shift+H,转行成打开show thread

[root@localhost ~]# printf "%x \n" 16381
3ffd

[root@localhost ~]# vi 16350.txt
2018-08-02 08:19:33
Full thread dump Java HotSpot(TM) Client VM (24.55-b03 mixed mode): "Attach Listener" daemon prio=10 tid=0xe081c800 nid=0x401a waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE "http-bio-8080-exec-3" daemon prio=10 tid=0xe0c99000 nid=0x3ffd runnable [0xe0a7a000]
java.lang.Thread.State: RUNNABLE
at com.huawei.jvm.Test.jvm01(Test.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.jav
a:137)

五:查看源代码:

定位出是while死循环引起

12_jvm性能优化专题1——top命令和jstack联合定位的更多相关文章

  1. SQLServer性能优化专题

    SQLServer性能优化专题 01.SQLServer性能优化之----强大的文件组----分盘存储(水平分库) http://www.cnblogs.com/dunitian/p/5276431. ...

  2. MySQL数据库性能优化专题

    摘录: 书:<MySQL性能调优与架构设计> 一个系列: (按顺序排一下) MySQL 数据库性能优化之缓存参数优化 http://isky000.com/database/mysql-p ...

  3. Linux 性能优化工具 perf top

    1. perf perf 是一个调查 Linux 中各种性能问题的有力工具. NAME perf - Performance analysis tools for Linux SYNOPSIS per ...

  4. jQuery EasyUI Datagrid性能优化专题

    jQuery  EasyUI的Datagrid组件功能算是很强大了,不过性能确实不怎么乐观,而对于性能问题,网络上几乎也找不到相关的优化资料,所谓的牛人们可能都望而却步了.本博客以后会带着分析Data ...

  5. jQuery EasyUI Datagrid性能优化专题(转)

    jQuery  EasyUI的Datagrid组件功能算是很强大了,不过性能确实不怎么乐观,而对于性能问题,网络上几乎也找不到相关的优化资料,所谓的牛人们可能 都望而却步了.本博客以后会带着分析Dat ...

  6. Unity性能优化专题---腾讯牛人分享经验

    这里从三个纬度来分享下内存的优化经验:代码层面.贴图层面.框架设计层面. 一.代码层面. 1.foreach. Mono下的foreach使用需谨慎.频繁调用容易触及堆上限,导致GC过早触发,出现卡顿 ...

  7. iOS性能优化专题

    http://wereadteam.github.io/2016/05/03/WeRead-Performance/ https://www.cnblogs.com/oc-bowen/p/599999 ...

  8. Unity3D性能优化--- 收集整理的一堆

    http://www.cnblogs.com/willbin/p/3389837.html 官方优化文档--优化图像性能http://docs.unity3d.com/Documentation/Ma ...

  9. 性能优化之Java(Android)代码优化

    最新最准确内容建议直接访问原文:性能优化之Java(Android)代码优化 本文为Android性能优化的第三篇——Java(Android)代码优化.主要介绍Java代码中性能优化方式及网络优化, ...

随机推荐

  1. 在jsp中如何使用javax.servlet.http.HttpServlet,javax.servlet.GenericServlet, javax.servlet.Servlet

  2. 刷题upupup【Java中HashMap、HashSet用法总结】

    HashMap: 常用操作 1. containsKey() 判断HashMap是否包含key 2. containsValue() 判断HashMap是否包含“值为value”的元素 3. get( ...

  3. oracle存储过程出现ORA-01403: 未找到数据 问题解决方法

    这段时间在做一个业务,需要用到存储过程处理业务逻辑,但是出现一个ORA-01403: 未找到数据 问题, 那么这个应该如何解决这个问题 declare mixType integer; begin - ...

  4. learning websocket protocol

    websocket的产生背景: 众所周知,Web应用的通信过程通常是客户端通过浏览器发出一个请求,服务器端接收请求后进行处理并返回结果给客户端,客户端浏览器将信息呈现.这种机制对于信息变化不是特别频繁 ...

  5. linux 虚拟机配置固定ip

    参考这边博客: https://blog.csdn.net/u014466635/article/details/80284792 但是这个有个小问题,就是没有配置dns,导致连不上公网 /etc/s ...

  6. SpringBoot配置ActiveMQ

    1.添加依赖 <!-- activeMQ --> <dependency> <groupId>org.springframework.boot</groupI ...

  7. JS案例六_1:添加城市

    使用的相关知识点:对子节点的添加:document.appendClild() 文本节点的创建:document.createTextNode() 元素节点的创建:document.createEle ...

  8. centos7初上手1-安装mysql数据库

    随着云服务器的普及,购入云服务器的门槛越来越低,对一个程序员来说,很多人会购买一款云服务器.以前买过两年windows服务器(没有什么实际用途,就是为了玩),最近有机会接触一下linux服务器,选择了 ...

  9. ESP32搭建3.ubuntu14.04下搭建esp32开发环境 (10-5)

    硬件为乐鑫出品的ESP32一款集成了wifi和蓝牙的集成模块. 1.首先ctrl+alt+t打开终端,sudo -s选择用root权限登陆 . 2. 输入指令:sudo apt-get install ...

  10. 实训任务04 MapReduce编程入门

    实训任务04 MapReduce编程入门 1.实训1:画图mapReduce处理过程 使用有短句“A friend in need is a friend in deed”,画出使用MapReduce ...