【JVM】问题排查
jetty的调用场景是:为了支持Servlet规范中的注解方式(使得不再需要在web.xml文件中进行Servlet的部署描述,简化开发流程),jetty在启动时会扫描class、lib包,将使用注解方式声明的Servlet、Listener注册到jetty容器,在扫描jar包的时候调用了inflate,分配了大量的内存,此时通过关键词搜索到Memory leak while scanning annotations,这篇文章给出了两种解决方法,一种是评论处所说,禁用缓存(说是jdk1.8的bug):
Here’s a link to the java bugs database issue: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8156014
I’d like to be able to comment on it, but I can’t seem to find a link to allow me to do that.
The comments I’d like to add are:
the problem is still reproduceable as of jdk8u112
the problem seems to be fixed in jdk9: I tested jdk9ea+149 and couldn’t reproduce
I’ve tried some workarounds for jdk8: it seems the ServiceLoader impl uses the jarurlconnection caching, so it may be of some benefit to try to disable url caching (although not sure of the effects on performance).
Try creating an xml file (eg called “caches.xml”) with the following contents:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Set class="org.eclipse.jetty.util.resource.Resource" name="defaultUseCaches">false</Set>
<New class="java.io.File">
<Arg>
<SystemProperty name="java.io.tmpdir"/>
</Arg>
<Call name="toURI">
<Call id="url" name="toURL">
<Call name="openConnection">
<Set name="defaultUseCaches">false</Set>
</Call>
</Call>
</Call>
</New>
</Configure>
尝试之后,java进程占用的物理内存由6.5G降到了5.9G,有一定的效果,但是我们估算的java进程应该占4.5G左右,还有1.4G内存被谁占用了呢?
再尝试另外一种方法:
We were investigating a Jetty application that used much more memory than it was supposed to do (near a Gb more than the max heap size plus the max metaspace size). We found out that the extra memory was Native memory, being allocated using malloc via some library (we don’t have native code in our app). Then we used jemalloc ( http://www.canonware.com/jemalloc/) to find out which class was doing this allocation and we found out that it was java.util.zip.Inflater. Via jstack we were able to find calls to the library and the main caller was Jetty, while in the process of looking for annotations. We disable annotations for the application and the memory usage went back to normal.
既然jetty调用是因为扫描jar包中的注解,我们应用中没有通过注解声明的Servlet、Listener,是不是可以不需要扫描这一步,故而在jetty.xml中将注解扫描的方式去掉:
<!-- <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item> -->
<!-- Item>com.xxx.boot.RJRAnnotationConfiguration</Item> -->
再重启应用,发现内存使用由6.5G降到了3.9G,并且应用运行稳定后不再占用swap,
出处:
http://www.longtask.net/2018/11/15/swap-used-full/#top
【JVM】问题排查的更多相关文章
- 我不是bug神(JVM问题排查)
Story background 回望2018年12月,这也许是程序员们日夜不得安宁的日子,皆因各种前线的系统使用者都需要冲业绩等原因,往往在这个时候会向系统同时写入海量的数据,当我们的应用或者数据库 ...
- 记一次jvm异常排查及优化
为方便自己查看,根据工作遇到的问题,转载并整理以下jvm优化内容 有次接到客服反馈,生产系统异常,无法访问.接到通知紧急上后台跟踪,查看了数据库死锁情况--正常,接着查看tomcat 内存溢出--正常 ...
- JVM 问题排查和性能优化常用的 JDK 工具
JDK 提供了一系列用于监控.诊断 Java 进程的工具,它们在 JDK 安装目录的 bin 目录下,有 jps.jcmd.jstack.jinfo.jmap 等.其中jmc.jconsole.jvi ...
- JVM问题排查工具:Serviceability-Agent介绍
本文首发于微信公众号:javaadu 简单介绍 构建高性能的Java应用过程中,必然会遇到各种各样的问题,像CPU飙高.内存泄漏.应用奔溃,以及其他疑难杂症,这时可以使用Serviceability ...
- JVM日常排查问题。基本操作和命令
1.jstat jstat -gcutil pid 5s //pid进程号 每隔5s监控一次内存回收情况 E 代表 Eden 区使用率:O(Old)代表老年代使用率 :P(Permanen ...
- JVM 问题排查常用工具
一. jmap // 打印jvm的堆状况,主要是年轻代和老年代信息 jmap -heap <pid> 如: Heap Configuration: MinHeapFreeRatio = M ...
- jvm问题排查工具、命令
dump生成:jmp -dump:live,format=b,file=/tmp/some.bin PID.其中,加上live表示只dump存活的对象. 线程栈信息生成:jstack PID > ...
- JVM 性能排查 自己做的笔记
Live Memory 1.Class Tracker 展示类或包的实例个数与时间的关系.需要录制才可以看到. 1)可以添加指定的类或包. 2.All Objects 查看所有类的实例个数和大小.可以 ...
- JVM 性能排查--汇总
参考:http://blog.sina.com.cn/s/blog_61d758500102wnus.html
- JVM 性能排查--查看哪个对象占用内存大
参考:http://blog.csdn.net/chenleixing/article/details/44227327/ 1. 在IE地址栏中输入:http://localhost/test/in ...
随机推荐
- Pinpoint在Win7下搭建
Pinpoint在Win7下搭建 注:原创作品,未经允许严禁转载 对于Pinpoint是什么这个问题,在此不做任何讨论,因此本篇文章适用人群为了解Pinpoint相关基础理论知识,需要进行Window ...
- 关于js的页面高度和滚动条高度还有元素高度
window.innerHeight 这是浏览器里面内容的高度,直接就是值,不需要其它操作; window.pageYOffset 这是滚动条到浏览器顶端的距离; $(元素).offset(). ...
- Java-JSON 解析
JSON JSON(JavaScript Object Notation, JS 对象简谱) 是一种轻量级的数据交换格式.它基于 ECMAScript (欧洲计算机协会制定的js规范)的一个子集,采 ...
- angular学习笔记(三)
1.安装npm install --save @angular/material@2.0.0-beta.72.安装http://chrome-extension-downloader.com安装aug ...
- Validator验证框架
Validator验证框架 系统分析 在设计Validator验证框架时,需要明确以下问题. (1)当用户没有输入数据时,弹出英文提示信息. (2)当用户输入的数据长度大于系统设置的数据长度,弹出英文 ...
- .net core2.1 使用 dynamic 类型报错
在net core2.0项目中使用 dynamic 无法编译通过 异常信息:缺少编译器要求的成员"Microsoft.CSharp.RuntimeBinder.CSharpArgumentI ...
- 中间人攻击——ARP欺骗的原理、实战及防御
1.1 什么是网关 首先来简单解释一下什么是网关,网关工作在OSI七层模型中的传输层或者应用层,用于高层协议的不同网络之间的连接,简单地说,网关就好比是一个房间通向另一个房间的一扇门. 1.2 A ...
- [Swift]LeetCode519. 随机翻转矩阵 | Random Flip Matrix
You are given the number of rows n_rows and number of columns n_cols of a 2D binary matrix where all ...
- [Swift]LeetCode771. 宝石与石头 | Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the ston ...
- Eclipse工具:常用快捷键记录
Eclipse快捷键: 按键操作 按键作用 输入sysout再按下Ctrl+Space System.out.println() Ctrl+1 当某行出错时时,跳出帮 ...