Tomcat内存消耗超过堆+ permgen空间 [英] Tomcat memory consumption is more than heap + permgen space

查看:425
本文介绍了Tomcat内存消耗超过堆+ permgen空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我观察到操作系统所说的内容与jVisualVM所说的内容之间的Tomcat RAM消耗不匹配。



从htop开始,Tomcat JVM已经 993 MB驻留内存

从jVisualVM,Tomcat JVM正在使用




  • 堆最大值:1,070,399,488 B

  • 堆大小: 298.438.656 B

  • 堆使用:变量,介于170MB之间和270MB

  • PermGen Max:268,435,456 B

  • PermGen尺寸: 248,872,960 B

  • PermGen使用:稍微变化,大约150MB



根据我的理解,操作系统内存消耗应该是堆大小+ PermGen大小〜= 522 MB但是,这比我观察的强471 MB



任何人都知道我在这里错过了什么?



PS:我知道我的最大堆远高于使用的,但我认为如果JVM不使用它应该没有效果(即堆大小较低)。



谢谢!
Marc

解决方案


根据我的理解,操作系统内存消耗应该是堆大小+ PermGen大小〜= 522 MB。但这比我观察到的要少471 MB。任何人都知道我在这里缺少什么?


如果我理解你所看到的问题是内存碎片和其他领域的JVM内存开销。我们经常看到生产程序的内存使用量是我们预期的内存设置的2倍。



内存碎片可能意味着虽然JVM认为操作系统已经给它一些字节数,但是有一些额外的字节数,必须由于内存子系统优化而给出。



就JVM开销而言,标准内存配置中还包含许多其他存储区域。这是关于此问题的良好讨论。引用:


以下
是不属于垃圾收集堆
的事实的示例是进程所需内存的一部分:




  • 实现JVM的代码

  • C实现JVM的数据结构的手动堆

  • 系统中所有线程的堆栈(app + JVM)

  • 缓存的Java字节码(用于库)和应用程序)

  • JITed机器代码(用于库和应用程序)

  • 所有已加载类的静态变量



I am observing a mismatch in Tomcat RAM consumption between what the OS says and what jVisualVM says.

From htop, the Tomcat JVM is has 993 MB of resident memory

From jVisualVM, the Tomcat JVM is using

  • Heap Max: 1,070,399,488 B
  • Heap Size: 298.438.656 B
  • Heap Used: variable, between 170MB and and 270MB
  • PermGen Max: 268,435,456 B
  • PermGen Size: 248,872,960 B
  • PermGen Used: slightly variable, around 150MB

From my understanding the OS memory consumption should be Heap Size + PermGen Size ~= 522 MB. But that's 471 MB less than what I'm observing.

Anyone got an idea what am I missing here?

PS: I know that my max heap is much higher than what is used, but I'm assuming that should have no effect if the JVM does not use it (i.e. Heap Size is lower).

Thanks! Marc

解决方案

From my understanding the OS memory consumption should be Heap Size + PermGen Size ~= 522 MB. But that's 471 MB less than what I'm observing. Anyone got an idea what am I missing here?

If I understand the question what you are seeing is a combination of memory fragmentation and JVM memory overhead in other areas. We often see 2 times the memory usage for our production programs than we would expect to see from our memory settings.

Memory fragmentation can mean that although the JVM thinks that the OS has given it some number of bytes, there is a certain addition number of bytes that had to be given because of memory subsystem optimizations.

In terms of JVM overhead, there are a number of other storage areas that are not included in the standard memory configs. Here's a good discussion about this. To quote:

The following are examples of things that are not part of the garbage collected heap and yet are part of the memory required by the process:

  • Code to implement the JVM
  • The C manual heap for data structures implementing the JVM
  • Stacks for all of the threads in the system (app + JVM)
  • Cached Java bytecode (for libraries and the application)
  • JITed machine code (for libraries and the application)
  • Static variables of all loaded classes

这篇关于Tomcat内存消耗超过堆+ permgen空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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