我是靠谱客的博主 文静河马,这篇文章主要介绍springboot jar启动的服务宕机了!——记一次JVM调优日志头部分--------------- T H R E A D ---------------堆栈及堆外内存解决问题,现在分享给大家,希望可以做个参考。

测试突然告诉我,请求报404,我一想,没关服务啊?

上服务器一看,服务挂了,生成了两个没见过的文件
在这里插入图片描述
看到文件名,猜测两个都是错误信息的相关文件,一个是日志,另一个文件比较大,应该是数据相关的

具体的日志文件各项参数释义,我参考了这篇博客:

https://blog.csdn.net/chenssy/article/details/78271744

日志头部分

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1349616 bytes for Chunk::new # Possible reasons: # The system is out of physical RAM or swap space # In 32 bit mode, the process size limit was hit # Possible solutions: # Reduce memory load on the system # Increase physical memory or swap space # Check if swap backing store is full # Use 64 bit Java on a 64 bit OS # Decrease Java heap size (-Xmx/-Xms) # Decrease number of Java threads # Decrease Java thread stack sizes (-Xss) # Set larger code cache with -XX:ReservedCodeCacheSize= # This output file may be truncated or incomplete. # # Out of Memory Error (allocation.cpp:390), pid=14884, tid=20960 # # JRE version: Java(TM) SE Runtime Environment (8.0_77-b03) (build 1.8.0_77-b03) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.77-b03 mixed mode windows-amd64 compressed oops) # Core dump written. Default location: D:****starths_err_pid14884.mdmp #

日志的开始部分介绍了本次jvm宕机的原因,以及一些可行的建议
这里面就是 关于启动堆栈,ReservedCodeCacheSize,java线程,等等的一些建议
当然具体的还要在往下看,找出真正的原因

--------------- T H R E A D ---------------

该部分是记录了导致出错的线程信息

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
--------------- T H R E A D --------------- Current thread (0x000000001c47b800): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=20960, stack(0x000000001dd70000,0x000000001de70000)] Stack: [0x000000001dd70000,0x000000001de70000] [error occurred during error reporting (printing stack bounds), id 0xc0000005] Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) Current CompileTask: C2:2329577 19219 4 com.fasterxml.jackson.databind.SerializerProvider::findValueSerializer (68 bytes)

堆栈及堆外内存

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Heap: PSYoungGen total 1352704K, used 1156756K [0x000000076ab00000, 0x00000007c0000000, 0x00000007c0000000) eden space 1326080K, 87% used [0x000000076ab00000,0x00000007b14a51e8,0x00000007bba00000) from space 26624K, 0% used [0x00000007bba00000,0x00000007bba00000,0x00000007bd400000) to space 38400K, 0% used [0x00000007bda80000,0x00000007bda80000,0x00000007c0000000) ParOldGen total 271360K, used 80217K [0x00000006c0000000, 0x00000006d0900000, 0x000000076ab00000) object space 271360K, 29% used [0x00000006c0000000,0x00000006c4e56538,0x00000006d0900000) Metaspace used 114910K, capacity 120592K, committed 120664K, reserved 1155072K class space used 13233K, capacity 14164K, committed 14208K, reserved 1048576K Card table byte_map: [0x0000000010b20000,0x0000000011330000] byte_map_base: 0x000000000d520000 Marking Bits: (ParMarkBitMap*) 0x000000006b8c0600 Begin Bits: [0x00000000122d0000, 0x00000000162d0000) End Bits: [0x00000000162d0000, 0x000000001a2d0000) Polling page: 0x0000000000130000 CodeCache: size=245760Kb used=52260Kb max_used=52260Kb free=193499Kb bounds [0x0000000001760000, 0x0000000004ad0000, 0x0000000010760000] total_blobs=15776 nmethods=15028 adapters=657 compilation: enabled

从上面的对信息中分析,能看出 Metaspace元空间提交内存大于使用内存

元空间Metaspace

这里补充下Metaspace元空间知识
参考链接:深入理解堆外内存Metaspace

从jdk7开始着手废除永久代PermGen,
jdk8工作完成,彻底用Metaspace代替了PermGen

Metaspace 区域位于堆外,所以它的最大内存大小取决于系统内存,而不是堆大小,我们可以指定 MaxMetaspaceSize 参数来限定它的最大内存。

参考链接:JVM学习——元空间(Metaspace)

为什么要用Metaspace替代方法区
随着动态类加载的情况越来越多,这块内存变得不太可控,如果设置小了,系统运行过程中就容易出现内存溢出,设置大了又浪费内存。

解决问题

从上面的元空间知识,可以得出猜测,本次的服务挂掉,是由于元空间内存占用过多,导致的宕机.

所以我们可以进行jvm启动参数设置,来避免这个问题.

复制代码
1
2
3
-XX:MetaspaceSize=2048m -XX:MaxMetaspaceSize=2048m

详细参数可以参考:JVM启动参数参考

最后

以上就是文静河马最近收集整理的关于springboot jar启动的服务宕机了!——记一次JVM调优日志头部分--------------- T H R E A D ---------------堆栈及堆外内存解决问题的全部内容,更多相关springboot内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(83)

评论列表共有 0 条评论

立即
投稿
返回
顶部