Mikhail Krestjaninoff中的“

Analyzing java memory usage in a Docker container”有一些线索:

Resident Set Size is the amount of physical memory currently allocated and used by a process (without swapped out pages). It includes the code, data and shared libraries (which are counted in every process which uses them)

Why does docker stats info differ from the ps data?

Answer for the first question is very simple – 07002: it includes file caches into the total memory usage info. So, we can just avoid this metric and use ps info about RSS.

Well, ok – but why is RSS higher than Xmx?

Theoretically, in case of a java application

RSS = Heap size + MetaSpace + OffHeap size

where OffHeap consists of thread stacks, direct buffers, mapped files (libraries and jars) and JVM code itse

Since 07003 we have 07004!

As you can see, I’ve already added -XX:NativeMemoryTracking=summary property to the JVM, so we can just invoke it from the command line:

docker exec my-app jcmd 1 VM.native_memory summary

(这是OP做的)

Don’t worry about the “Unknown” section – seems that NMT is an immature tool and can’t deal with CMS GC (this section disappears when you use an another GC).

Keep in mind, that NMT displays “committed” memory, not “resident” (which you get through the ps command). In other words, a memory page can be committed without considering as a resident (until it directly accessed).

That means that NMT results for non-heap areas (heap is always preinitialized) might be bigger than RSS values.

As a result, despite the fact that we set the jvm heap limit to 256m, our application consumes 367M. The “other” 164M are mostly used for storing class metadata, compiled code, threads and GC data.

First three points are often constants for an application, so the only thing which increases with the heap size is GC data.

This dependency is linear, but the “k” coefficient (y = kx + b) is much less then 1.

更普遍的是,这似乎是issue 15020之后,报告了自从Docker 1.7以来的类似问题

I’m running a simple Scala (JVM) application which loads a lot of data into and out of memory.

I set the JVM to 8G heap (-Xmx8G). I have a machine with 132G memory, and it can’t handle more than 7-8 containers because they grow well past the 8G limit I imposed on the JVM.

07007 shows that each container itself is using much more memory than the JVM is supposed to be using. For instance:

CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O

dave-1 3.55% 10.61 GB/135.3 GB 7.85% 7.132 MB/959.9 MB

perf-1 3.63% 16.51 GB/135.3 GB 12.21% 30.71 MB/5.115 GB

It almost seems that the JVM is asking the OS for memory, which is allocated within the container, and the JVM is freeing memory as its GC runs, but the container doesn’t release the memory back to the main OS. So… memory leak.

java jvm容器_在Docker容器中运行的JVM的驻留集大小(RSS)和Java总承诺内存(NMT)之间的差异...相关推荐

  1. docker和java容器_使用Docker容器和Java EE进行持续交付

    docker和java容器 组织需要一种使应用程序交付快速,可预测和安全的方法,而诸如docker之类的容器所提供的敏捷性则可以帮助开发人员实现这一目标. 对于Java EE应用程序,这可以在容器中打 ...

  2. docker配置容器mysql启动参数_修改Docker容器启动配置参数

    有时候,我们创建容器时忘了添加参数 --restart=always ,当 Docker 重启时,容器未能自动启动, 现在要添加该参数怎么办呢,方法有二: 1.Docker 命令修改 docker c ...

  3. docker 关闭所有容器_软件安全 : Docker逃逸详解

    前言 在虚拟化技术日益成熟的今天,Docker作为必须使用的一项服务,它的安全性尤为重要.今天,我们来一起学习Docker最大的安全威胁--逃逸技术. Docker是什么 Docker 是一个开源的应 ...

  4. docker中java钩子_springboot项目在docker容器中如何优雅关闭

    前言 什么是优雅关闭 在我看来所谓的优雅关闭,就是在系统关闭时,预留一些时间,让你有机会来善后一些事情 什么时候需要优雅关闭 是否所有项目都需要优雅关闭?那也不一定,毕竟所谓的优雅关闭,另一面就意味这 ...

  5. linux修改容器内的mysql端口映射_修改docker容器端口映射的方法

    大家都知道docker run可以指定端口映射,但是容器一旦生成,就没有一个命令可以直接修改.通常间接的办法是,保存镜像,再创建一个新的容器,在创建时指定新的端口映射. 有没有办法不保存镜像而直接修改 ...

  6. 容器宿主机数据库_解决Docker容器内访问宿主机MySQL数据库服务器的问题

    懒得描述太多,总归是解决了问题,方法简要记录如下,虽然简要,但是完整,一来纪念处理该问题耗费的大半天时间,二来本着共享精神帮助其他遇到该问题的哥们儿,当然这个方法并不一定能解决你们的问题,但是多少能提 ...

  7. iso镜像添加软件包_超薄Docker容器-减少Docker镜像大小的指南

    Photo by William Warby on Unsplash 您是否曾经想过为什么您的单应用程序Docker容器会增长到400 MB? 或者,也许为什么一个只有几十MB的应用程序二进制文件会生 ...

  8. docker 代理_利用Docker容器实现代理转发和数据备份

    我们将应用以Docker容器的方式部署到服务器上的时候,通常需要考虑两个方面的的问题:网络和存储. 网络方面,有些应用需要占用端口,而其中一部分应用甚至需要对外提供访问. 出于安全方面考虑,代理转发方 ...

  9. docker 日志_解决docker容器日志导致主机磁盘空间满了的情况

    日志文件在 /var/lib/docker/containers// 目录下 查看日志大小 vim /opt/docker_log_size.sh #!/bin/shecho "====== ...

最新文章

  1. 00截断上传绕过_【文件上传与解析】文件上传与解析漏洞总结v1.0
  2. 配置Apache时出错及解决方法
  3. 【HDU - 1520】Anniversary party (树形dp)
  4. 让VMware ESXi 5.5与Windows时间服务器同步
  5. 下载哨兵1精轨数据教程
  6. 计算机组装配置兼容,菜鸟DIY装机必须注意的五大硬件兼容性问题
  7. 解决:115网盘下载路径失败
  8. 90KB的3D游戏(像CS一样)[汇编界又一奇迹]绝对震撼,操作和CS一样!
  9. 数据竞赛修炼笔记之快手用户活跃度的预测
  10. NotADirectoryError: [WinError 267] 目录名称无效和OSError: [Errno 22] Invalid argument:解决办法
  11. 自动化测试金字塔与反模式
  12. 干货 | 一文读懂数据分析
  13. Centos Linux 6.5 破解root密码
  14. Unsupervised Learning of Visual Features by Contrasting Cluster Assignments(SwAV)---论文阅读笔记
  15. SRT字幕的颜色以及一些特效的设置
  16. Spark的安装及下载
  17. 华为机试2022.4.13:硬件资源分配
  18. android uil,Android UIL图片加载框架学习
  19. 迷宫问题(搜索+回溯)
  20. 【Jinja2】模板继承(八)

热门文章

  1. 2021-2025年中国顶灯行业市场供需与战略研究报告
  2. vue-router下的html5 history在iis服务器上的设置 vue去掉#
  3. php cpu型号,linux如何查看cpu型号?
  4. 【IT】学生数据库小结2
  5. 你究竟值多少钱?2021 科技行业薪酬分析
  6. 燃烧吧!开发者们,一起在云端构建开放成熟的 ARM 生态!
  7. 通过代码学 Sutton 强化学习:SARSA、Q-Learning 时序差分算法训练 CartPole
  8. 重量级!Maven史上最全教程,看了必懂
  9. “Talk is cheap, show me the code”你一行代码有多少漏洞?
  10. 朱啸虎回应“美团滴滴合并”;小米成世界第四大手机制造商;Ant Design 3.26.1 发布 | 极客头条...