Java内存之谜(我有泄漏)? [英] Java memory mystery (do I have a leak)?

查看:191
本文介绍了Java内存之谜(我有泄漏)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linux服务器上运行一个独立的Java问题。我用-Xmx256m启动了jvm。我附加了一个JMX监视器,可以看到堆永远不会真正通过256Mb。但是,在我的linux系统上运行top命令时,我可以看到:

I have a standalone Java problem running in a linux server. I started the jvm with -Xmx256m. I attached a JMX monitor and can see that the heap never really passes 256Mb. However, on my linux system when I run the top command I can see that:

1)首先,此进程的RES内存使用量约为350Mb。为什么?我想这是因为堆外的内存?

1) First of all, the RES memory usage of this process is around 350Mb. Why? I suppose this is because of memory outside of the heap?

2)其次,这个过程的VIRT内存使用量不断增长和增长。它永远不会停止!它现在显示在2500Mb!我有泄漏吗?但堆不会增加,它只是循环!

2) Secondly, the VIRT memory usage of this process just keeps growing and growing. It never stops! It now shows at 2500Mb! So do I have a leak? But heap doesn't increase, it just cycles!

最终这会带来一个问题,因为系统的交换不断增长,最终导致系统死亡。

Ultimately this poses a problem because the swap of the system keeps growing and eventually the system dies.

任何想法是怎么回事?

我想问的一个重要问题,这可能是我的代码而不是JVM,kernal等的一些情况。例如,如果线程数量不断增长,那将符合我的观察结果的描述?您可以建议我注意哪些类似的东西?

推荐答案

一些潜在的问题:


  • 直接分配的缓冲区和内存映射文件在Java堆外部分配,无法方便地处理。

  • 为每个新线程保留一个堆栈区域。

  • 永久生成(代码和实习字符串)超出了通常的堆栈。这可能是一个问题,类加载器泄漏(通常在重新加载webapps时)。

  • C堆可能正在泄漏。

  • Direct allocated buffers and memory mapped files are allocated outside of the Java heap, and can't conveniently be disposed.
  • An area of stack is reserved for each new thread.
  • Permanent generation (code and interned strings) is outside of the usual stack. It can be a problem is class loaders leak (usually when reloading webapps).
  • It's possible that the C heap is leaking.

pmap -x 应该显示你的记忆是如何消失的。

pmap -x should show how your memory has disappeared.

这篇关于Java内存之谜(我有泄漏)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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