Java堆转储和堆分析后的堆大小不同 [英] Java heap dump and the heap size after the heap analysis differs

查看:131
本文介绍了Java堆转储和堆分析后的堆大小不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到内存泄漏,这里有一些细节.

I am experiencing memory leak and here goes some detail.

泄漏后,

  • 顶部显示50GB的内存为住宅
  • 堆转储文件大小为25GB
  • eclipse MAT分析器告诉我堆大小为10GB

泄漏前,

  • 顶部显示30GB的内存为住宅
  • 堆转储文件大小为20GB
  • eclipse MAT分析器告诉我堆大小为10GB

对于top,堆转储大小和实际堆大小之间的差异,我感到非常惊讶. 我猜想top和heap之间的区别是垃圾收集器堆和本机堆区域的可能性. 但是,堆转储文件的大小和实际堆大小(通过eclipse MAT分析器得出)为何会有所不同?

I am pretty surprised that the difference between top, heap-dump size, and the actual heap size. I am guessing that the difference between top and heap is the possibility of garbage collector heap and native heap areas. But, how come the heap dump file size and the actual heap size (from eclipse MAT analyzer) could differ?

对这个问题有见识吗?

更新/答复

一些建议是使用jcmd( https网站指示本机内存跟踪"时,://://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr007.html ).但是,如果您仔细阅读该页面,将会看到

Some of suggestions are to use jcmd (https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr007.html) as the website tells "Native Memory Tracking". But, if you read the page carefully, you will see

由于NMT不会通过非JVM代码跟踪内存分配,因此您可以 必须使用操作系统支持的工具来检测内存 本机代码泄漏.

Since NMT doesn't track memory allocations by non-JVM code, you may have to use tools supported by the operating system to detect memory leaks in native code.

因此,如果本机库内部发生泄漏,则无法选择jcmd.

So, in case of the leak inside the native library, jcmd is not an option.

在搜寻了数天的Internet并尝试了各种探查器之后,最有效的解决方法是使用 jemalloc 探查器.

After crawling the Internets for days and trying out various profilers, most effective for this problem is using jemalloc profiler.

此页面对我有很大帮助!

This page helped me a lot! https://gdstechnology.blog.gov.uk/2015/12/11/using-jemalloc-to-get-to-the-bottom-of-a-memory-leak/

推荐答案

top和其他操作系统级别的工具显示JVM进程消耗了多少系统内存.由-Xmx命令行选项定义的Java堆只是该内存的一部分.除了堆之外,JVM本身还需要一些内存.然后是java线程,每个线程都需要一定数量的内存.和元空间/永久生成.还有其他几个.您可以阅读此博客帖子

top and other OS level tools show how much system memory does your JVM process consume. Java heap, defined by -Xmx command line option, is only a part of that memory. Apart from heap JVM needs some memory for itself. Then there are java threads, each requiring a certain amount of memory. And Metaspace/Permanent Generation. And several others. You can read this blog post and this SO answer for more information.

关于转储文件的大小和实际堆的大小,@ arnab-biswas的答案肯定是正确的. MAT报告活动对象消耗的实际使用堆的大小.但是堆转储包含了整个堆,包括垃圾.

About the size of the dump file and the actual heap size the answer of @arnab-biswas is certainly true. MAT reports the size of actually used heap, consumed by live objects. But heap dump contains the whole of the heap, including garbage.

这篇关于Java堆转储和堆分析后的堆大小不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆