JVM--调优--04--案例08--元空间不够导致FULL GC

JVM–调优–04–案例08–元空间变大导致FULL GC


1、现象

应用经常宕机。

1.1、日志

{Heap before GC invocations=1 (full 1):
def new generation total 1258368K, used 581671K [0x00000005c0000000, 0x0000000615560000, 0x000000066aaa0000)
eden space 1118592K, 52% used [0x00000005c0000000, 0x00000005e3809c70, 0x0000000604460000)
from space 139776K, 0% used [0x0000000604460000, 0x0000000604460000, 0x000000060cce0000)
to space 139776K, 0% used [0x000000060cce0000, 0x000000060cce0000, 0x0000000615560000)
tenured generation total 2796224K, used 15985K [0x000000066aaa0000, 0x0000000715550000, 0x00000007c0000000)
the space 2796224K, 0% used [0x000000066aaa0000, 0x000000066ba3c6e0, 0x000000066ba3c800, 0x0000000715550000)
Metaspace used 34435K, capacity 35373K, committed 35416K, reserved 1079296K
class space used 4370K, capacity 4653K, committed 4696K, reserved 1048576K
9.469: [Full GC (Metadata GC Threshold) TLAB: gc thread: 0x000055fa30914000 [id: 31] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 99.9% gc: 22895624B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa30911800 [id: 30] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 100.0% gc: 22908760B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa308eb800 [id: 27] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 99.9% gc: 22890808B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa308e9800 [id: 26] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 95.9% gc: 21973168B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa308bf800 [id: 25] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 95.9% gc: 21963984B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa3082f000 [id: 22] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 94.2% gc: 21572864B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa30810000 [id: 21] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 99.6% gc: 22819488B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa30800800 [id: 20] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 99.3% gc: 22737328B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa307ab000 [id: 18] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 99.9% gc: 22890280B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa2f127000 [id: 16] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 1 waste 100.0% gc: 22908672B slow: 0B fast: 0B
TLAB: gc thread: 0x000055fa2f07c800 [id: 13] desired_size: 22371KB slow allocs: 0 refill waste: 357944B alloc: 1.00000 581671KB refills: 15 waste 3.3% gc: 11358880B slow: 1720B fast: 0B
TLAB totals: thrds: 11 refills: 25 max: 15 slow allocs: 0 max 0 waste: 41.4% gc: 236919856B max: 22908760B slow: 1720B max: 1720B fast: 0B max: 0B
9.470: [Tenured: 15985K->31407K(2796224K), 0.1904343 secs] 597656K->31407K(4054592K), [Metaspace: 34435K->34435K(1079296K)], 0.1906582 secs] [Times: user=0.24 sys=0.01, real=0.19 secs]
Heap after GC invocations=2 (full 2):
def new generation total 1258368K, used 0K [0x00000005c0000000, 0x0000000615560000, 0x000000066aaa0000)
eden space 1118592K, 0% used [0x00000005c0000000, 0x00000005c0000000, 0x0000000604460000)
from space 139776K, 0% used [0x0000000604460000, 0x0000000604460000, 0x000000060cce0000)
to space 139776K, 0% used [0x000000060cce0000, 0x000000060cce0000, 0x0000000615560000)
tenured generation total 2796224K, used 31407K [0x000000066aaa0000, 0x0000000715550000, 0x00000007c0000000)
the space 2796224K, 1% used [0x000000066aaa0000, 0x000000066c94bef8, 0x000000066c94c000, 0x0000000715550000)
Metaspace used 34435K, capacity 35373K, committed 35416K, reserved 1079296K
class space used 4370K, capacity 4653K, committed 4696K, reserved 1048576K
}
9.660: Total time for which application threads were stopped: 0.1913185 seconds, Stopping threads took: 0.0001483 seconds
10.142: Application time: 0.4812853 seconds
10.143: Total time for which application threads were stopped: 0.0012404 seconds, Stopping threads took: 0.0000766 seconds
10.144: Application time: 0.0007587 seconds
10.144: Total time for which application threads were stopped: 0.0007876 seconds, Stopping threads took: 0.0000530 seconds
10.176: Application time: 0.0320494 seconds
10.178: Total time for which application threads were stopped: 0.0015167 seconds, Stopping threads took: 0.0001305 seconds
10.366: Application time: 0.1881530 seconds

1.1、字段说明

9.469: [Full GC (Metadata GC Threshold) TLAB: gc thread: 0x000055fa30914000 [id: 31] 
desired_size: 22371KB 
slow allocs: 0  
refill waste: 357944B 
alloc: 1.00000   581671KB 
refills: 1 waste 99.9% 
gc: 22895624B slow: 0B fast: 0B
  1. 9.469: 这是GC事件发生的时间戳,表示自JVM启动以来的秒数。
  2. [Full GC (Metadata GC Threshold)]: 这表示发生了一次完全垃圾收集(Full GC),并且触发这次GC的原因是元数据GC阈值(Metadata GC Threshold)被达到。在JVM中,元数据通常指的是类的元数据,比如类的结构信息。当这些元数据占用的空间超过了某个阈值时,就会触发Full GC来清理这些不再使用的元数据。
  3. TLAB: 这是线程本地分配缓冲区(Thread-Local Allocation Buffer)的缩写。TLAB是JVM为每个线程分配的私有内存区域,用于加速对象分配。
  4. gc thread: 0x000055fa30914000 [id: 31]: 这是执行此次GC的线程的信息,包括其地址和ID。
  5. desired_size: 22371KB: 这可能是指TLAB期望的大小,即JVM希望为每个线程分配的TLAB大小。
  6. slow allocs: 0: 这表示在TLAB分配过程中,因为TLAB空间不足而需要进行慢速分配的次数为0。
  7. refill waste: 357944B: 这表示在重新填充TLAB时浪费的空间大小。
  8. alloc: 1.00000: 这可能是表示TLAB的利用率或某种分配率,但具体含义需要查看JVM的文档或源代码来确定。
  9. 581671KB: 这可能是与TLAB或此次GC事件相关的某种内存大小。
  10. refills: 1: 这表示TLAB被重新填充的次数。
  11. waste 99.9%: 这表示在TLAB重新填充或GC过程中浪费的空间比例。
  12. gc: 22895624B: 这表示此次GC回收的内存大小。
  13. slow: 0B fast: 0B: 这表示慢速和快速分配的内存大小,但在这个日志中它们都是0,可能表示没有发生慢速或快速分配。

1.2、分析

  1. 上面可以看到,元空间不够,导致了一次Full GC。
  2. TLAB 空间浪费非常高,大于90%,可以设置TLAB的大小
    1. 使用-XX:TLABWasteTargetPercent设置TLAB占用Eden空间的百分比。这个参数允许你调整TLAB的大小,以适应你的应用程序的内存分配模式。默认情况下,TLAB的空间很小,仅占整个Eden空间的1%

1.2、解析

2、解决

  1. 调整TLAB大小
  2. 增大元数据空间
  3. 升级JVM版本
  • 22
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
JVM调优工具命令详解》是一份预习资料,主要介绍了Java虚拟机(JVM调优过程中使用的一些工具命令。这些工具命令可以帮助开发人员诊断和优化JVM的性能问题。 文中首先介绍了常用的JVM调优工具命令,包括jps、jstat、jinfo、jmap、jhat等。这些命令可以用于查看JVM进程信息、统计JVM内存和线程情况、获取JVM配置参数等。通过使用这些工具命令,开发人员可以快速定位JVM性能瓶颈所在,进行优化。 接下来,文中详细介绍了每个工具命令的使用方法和参数解释。例如,jstat命令可以用于查看JVM内存情况,包括堆内存使用量、垃圾回收情况等。而jmap命令可以用于生成堆内存转储文件,帮助开发人员分析内存泄漏问题。通过掌握这些工具命令的使用,开发人员可以更加高效地进行JVM调优。 此外,文中还介绍了一些实际的调优案例,通过使用这些工具命令来解决实际的JVM性能问题。这些案例包括内存泄漏、线程死锁、CPU占用过高等问题。通过学习这些案例开发人员可以更好地理解如何利用工具命令来诊断和解决JVM性能问题。 总的来说,《JVM调优工具命令详解》是一份非常实用的预习资料,适合那些需要深入学习JVM性能优化的开发人员。通过学习和掌握这些工具命令,开发人员能够更加高效地进行JVM调优,提升应用程序的性能和稳定性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值