Java 试图找到泄漏点!anon 对 pmap 意味着什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1477885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trying to locate a leak! What does anon mean for pmap?
提问by erotsppa
I'm trying to locate where my memory has gone for a java process running in linux. Someone suggested I use pmap -x to see exactly what the memory is doing.
我正在尝试找到在 linux 中运行的 java 进程的内存在哪里。有人建议我使用 pmap -x 来准确查看内存在做什么。
The output is really long but basically a good portion of it is a repeat of this:
输出真的很长,但基本上其中很大一部分是重复的:
00007fbf75f6a000 1016 - - - rwx-- [ anon ]
00007fbf76068000 12 - - - ----- [ anon ]
What exactly does this mean? Why do I have so many entries of this (4000+)?
这到底是什么意思?为什么我有这么多条目(4000+)?
采纳答案by kdgregory
Anon blocks are "large" blocks allocated via malloc or mmap -- see the manpages. As such, they have nothing to do with the Java heap (other than the fact that the entire heap should be stored in just such a block).
Anon 块是通过 malloc 或 mmap 分配的“大”块——请参阅联机帮助页。因此,它们与 Java 堆无关(除了整个堆应该存储在这样的块中这一事实之外)。
In my experience, thread stacks also use anon blocks. If you see a lot of anon blocks that all have the same size, and that size is 512k to 4Mb (the example below is repeated over a dozen times for a Tomcat process that I have running), that's the likely cause. Depending on the program, you may have up to a few dozen of these; if you're seeing thousands, it means you have a problem with threading.
根据我的经验,线程堆栈也使用匿名块。如果您看到许多匿名块都具有相同的大小,并且该大小为 512k 到 4Mb(对于我正在运行的 Tomcat 进程,下面的示例重复了十几次),这就是可能的原因。根据程序的不同,您可能有多达几十个;如果您看到数千个,则意味着您在线程处理方面存在问题。
b089f000 504K rwx-- [ anon ]
b091d000 12K ----- [ anon ]
b0920000 504K rwx-- [ anon ]
b099e000 12K ----- [ anon ]
b09a1000 504K rwx-- [ anon ]
b0a1f000 12K ----- [ anon ]
But that leaves a question: why are you using pmapto diagnose a Java memory issue?
但这留下了一个问题:为什么要使用pmap来诊断 Java 内存问题?
回答by Zed
回答by eckes
Use Eclipse MAT (when you get OutOfMemoryExceptions in the Java Heap not the native heap).
使用 Eclipse MAT(当您在 Java 堆而不是本机堆中获得 OutOfMemoryExceptions 时)。
回答by teknopaul
I've seen that pattern before in a thread leak. If you have code that is trying to pool threads, but somehow messes up and leaks a thread, you get a pattern like that in pmap.
我以前在线程泄漏中看到过这种模式。如果您的代码试图将线程池化,但不知何故搞砸并泄漏了一个线程,您将在 pmap 中得到类似的模式。
I think each bit of memory is the minimum stack size for the thread, certainly it had nothing to do with heap in our case.
We still got OutOfMemoryErrors when we hit OS limits, even tho when we analise the heap it is not overallocated.
我认为每一位内存都是线程的最小堆栈大小,当然在我们的例子中它与堆无关。
当我们达到操作系统限制时,我们仍然会遇到 OutOfMemoryErrors,即使我们分析堆并没有过度分配。
When we had a problem like this pmap [pid] | grep -c 12K
turned out to be the number of threads in use.
当我们遇到这样的问题pmap [pid] | grep -c 12K
时,结果是正在使用的线程数。