频道
bg

JVM进程启动被杀

coding一月 11, 20231mins
Java

Kill process or sacrifice child | Plumbr - User Experience & Application Performance Monitoring

诊断H1

查看内核日志,JVM进程被杀dmesg -T

jsx

Jun 4 07:41:59 plumbr kernel: [70667120.897649] Out of memory: Kill process 29957 (java) score 366 or sacrifice child
Jun 4 07:41:59 plumbr kernel: [70667120.897701] Killed process 29957 (java) total-vm:2532680kB, anon-rss:1416508kB, file-rss:0kB

Linux 内核内存配置H1

/proc/meminfo中可以看到内存超配阈值

jsx

# grep -i commit /proc/meminfo
CommitLimit: 5967744 kB
Committed_AS: 5363236 kB
  • CommitLimit 就是overcommit的阈值,它是通过内核参数vm.overcommit_ratiovm.overcommit_kbytes间接设置的,公式如下: CommitLimit = (Physical RAM * vm.overcommit_ratio / 100) + Swap
  • Committed_AS 表示所有进程已经申请的内存总大小,

内核参数 vm.overcommit_memory 为超配策略

  • 0 – Heuristic overcommit handling. 这是缺省值,它允许overcommit,但过于明目张胆的overcommit会被拒绝,比如malloc一次性申请的内存大小就超过了系统总内存。Heuristic的意思是“试探式的”,内核利用某种算法(对该算法的详细解释请看文末)猜测你的内存申请是否合理,它认为不合理就会拒绝overcommit。
  • 1 – Always overcommit. 允许overcommit,对内存申请来者不拒。
  • 2 – Don’t overcommit. 禁止overcommit。

理解Linux的memory overcommit

内存占用H1

topH2

  • VIRT:virtual memory usage 虚拟内存 进程“需要的”虚拟内存大小,包括进程使用的库、代码、数据等
  • RES:resident memory usage 常驻内存 ****进程当前使用的内存大小,但不包括swap out,包含其他进程的共享

jvmH2

jmap -heap 2196

NMTH3

开启

jsx

-XX:NativeMemoryTracking=[off | summary | detail]

查看

jsx

jcmd <pid> VM.native_memory

Untitled

为什么设置-Xmx4g但是java进程内存占用达到8g?斗者_2013的博客-CSDN博客-xms4g

JVM内存设置H1

–Xms512m –Xmx1024m 参数要设置在Jar文件的前面,否则不起作用

jsx

java –Xms512m –Xmx1024m –jar ems-client-1.0.jar

jvm疯狂吞占内存,罪魁祸首是谁?-易观分析

Understanding the Linux oom-killer’s logs

评论


新的评论

匹配您的Gravatar头像

Joen Yu

@2022 JoenYu, all rights reserved. Made with love.