驻留集大小(RSS)和一个Java的JVM总提交的内存(NMT)之间的差异泊坞窗容器中运行

sunsin1985:

场景:

我有一个JVM在泊坞窗容器中运行。我没有使用两个工具的一些内存分析:1)顶部 2)Java本机内存跟踪这些数字看起来很奇怪,我试图找到造成差异什么。

题:

该RSS报告为1272MB的Java进程和总Java内存报告为790.55 MB。我如何解释哪儿来的内存1272的其余部分 - 790.55 = 481.44 MB去?

为什么我要连看后让这个问题打开了这个问题上的SO:

我没有看到答案和解释是有道理的。然而,从Java NMT和PMAP -x获得输出之后,我仍然不能够具体地图,Java的内存地址实际上是居民和物理图谱我需要一些具体的解释(有详细步骤)找到造成RSS和Java总之间的差异最新提交的内存。

顶部出

在这里输入图像描述

Java的NMT

在这里输入图像描述

泊坞窗内存统计

在这里输入图像描述

图表

我对大多数超过48小时运行的泊坞窗容器。现在,当我看到其中包含的图形:

  1. 给予搬运工容器总内存= 2 GB
  2. Java的最大堆= 1 GB
  3. 总承诺(JVM)=总是小于800 MB
  4. 堆使用(JVM)=总是小于200 MB
  5. 非堆使用(JVM)=总是小于100 MB。
  6. RSS = 1.1左右GB。

那么,什么吃1.1 GB(RSS)和800 MB的内存(Java的总提交的内存)?

在这里输入图像描述

VonC:

You have some clue in " Analyzing java memory usage in a Docker container" from Mikhail Krestjaninoff:

(And to be clear, in May 2019, three years later, the situation does improves with openJDK 8u212 )

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 - Docker has a bug (or a feature - depends on your mood): 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 JDK 1.8.40 we have Native Memory Tracker!

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

(This is what the OP did)

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.

(that is where "Why does a JVM report more committed memory than the linux process resident set size?" comes in)

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.


More generally, this seems to be followed by issue 15020 which reports a similar issue since docker 1.7

我运行一个简单的斯卡拉(JVM)的应用程序,加载大量数据移入和移出内存。
我设置了JVM到8G堆(-Xmx8G)。我有一台机器与132G内存,因为它们生长早已过了8G限制我在JVM上强加它不能处理超过7-8容器。

docker stat报道误导之前,因为它显然包括文件缓存到内存使用总量的信息)

docker stat每个容器本身是使用比JVM更多的内存显示是应该使用。例如:

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

它几乎似乎JVM是要求存储操作系统,这是在容器内分配,并将JVM释放内存为GC运行,但容器不释放内存回主操作系统。所以...内存泄漏。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

与Linux VmRSS和Java NativeMemoryTraking(NMT)的总提交内存的差异

如何安装SQL Server Java驱动程序到一个Linux泊坞窗容器?

泊坞窗撰写:重建一个链接的容器中断了nginx的上游

在泊坞窗容器中运行的Java GUI应用程序

如何指定一个共享泊坞窗卷的大小?

如何使用Python和Java运行泊坞窗?

在泊坞窗容器中运行时,高I / O Java进程中始终得到信号11 SIGSEGV在JavaThread

泊坞窗和Java - FontConfiguration问题

泊坞窗服务如何设法从单独的泊坞窗容器中调用实例?

如何运行Hetionet v1.0泊坞窗容器?

泊坞窗:在启动容器时设置运行用户

在OpenShift中运行Nginx泊坞窗容器的正确方法是什么?

无法执行从一个泊坞窗映像到另一个泊坞窗映像的API请求

泊坞窗网络链接到2个或多个容器

泊坞窗-尽管在容器中找不到AWS凭证

泊坞窗:创建一个mongodb卷,在docker-compose down之后仍保存吗?

在泊坞窗运行Java应用程序12

与Java的许可问题,运行泊坞窗

为什么JVM报告的已提交内存比linux进程驻留集大小更多?

泊坞窗重新启动容器失败:“已在使用中”,但是没有更多泊坞窗映像

无法在同一泊坞窗中连接Node.js和MySQL

Java的11个应用轻质泊坞窗图像

清漆泊坞窗容器无响应

自动拉泊坞窗图像容器

泊坞窗撰写构建单个容器

泊坞窗无法指定容器连接

一个泊坞窗用户可以向另一个隐藏数据吗?

创建了一个可安装nginx,python,uwsgi和django的泊坞窗。如何在VM中进行测试?

泊坞窗 - 运行码头上的HTTPS