简体   繁体   English

交换内存连续性增加

[英]Swap memory continuolsy increasing

I have a web application running in glassfish in RHEL. 我在RHEL的glassfish中运行了一个Web应用程序。 For the application, these are set: 对于应用程序,这些设置如下:

Heap Memory:4GB
Perm Gen:1GB

JConsole shows: JConsole显示:

heap memory - 500mb
non heap memory - 350mb 
threads =378

Top shows: 热门节目:

PID   User       PR  NI  VIRT RES  SHR S  %CPU  %MEM   TIME+   COMMAND
17948 root       20   0 12.8g 1.9g  22m S  1.5   16.0  14:09.11 java

From starting itself process is consuming 12.8G. 从开始本身的过程开始就消耗12.8G。

Top also shows: 顶部还显示:

Mem:  12251392k total, 11915584k used,   335808k free,    47104k buffers
Swap:  8322944k total,  6747456k used,  1575488k free,   177088k cached

The problem is swap space is continuosly increasing. 问题是交换空间在不断增加。 When no swap space is left, the web application stops respondng. 如果没有交换空间,Web应用程序将停止响应。

  1. Killing process does not reduces used swap space but only after computer reboot. 杀死进程不会减少使用的交换空间,而只会在计算机重新启动后才会减少。 Why? 为什么?
  2. Why is the process consuming 12.8 GB of virtual space when started? 为什么该进程在启动时会消耗12.8 GB的虚拟空间?
  3. How to approach to resolve this issue? 如何解决这个问题?

Update: 更新:

The jconsole output(recorded for 24 hours) shows that heap memory and non heap memory didn't increase much. jconsole输出(记录了24小时)显示堆内存和非堆内存没有增加太多。 Even though the swap space redcued by 1.5Gb in the same period: Jconsole output 即使交换空间在同一时期减少了1.5Gb: Jconsole输出

You could have a look at these answers to get an impression of the meaning of top's output. 您可以看一下这些答案,以了解top输出的含义。 You can use a script to roughly report what uses your swap space. 您可以使用脚本来大致报告使用交换空间的内容。

To my knowledge Linux' swap system is not that straightforward. 据我所知,Linux的交换系统并不是那么简单。 The kernel first swaps out inactive memory, probably other application's memory, to give GF enough resources. 内核首先换出不活动的内存(可能是其他应用程序的内存),以便为GF提供足够的资源。 This will not be instantly swapped back in when GF is terminated. GF终止后,不会立即将其交换回去。 You could try to swapoff -a to force Linux to swap things back in, but remember to re-enable it via swapon -a . 您可以尝试交换swapoff -a来强制Linux重新交换东西,但是请记住通过swapon -a重新启用它。

The VIRT space due to top's manpage: top的联机帮助页为VIRT提供了空间:

The total amount of virtual memory used by the task. 任务使用的虚拟内存总量。 It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used. 它包括所有代码,数据和共享库,以及换出的页面和已映射但未使用的页面。

I doubt that the OS reports on memory usage are that good in order to debug your Java application. 我怀疑操作系统的内存使用报告是否能调试您的Java应用程序。 You should have a look into your JVM's memory with tools like JVisualVM (part of Oracle's JDK). 您应该使用JVisualVM (Oracle JDK的一部分)之类的工具查看JVM的内存。 Observe the progress of memory usage for a relevant period of time. 观察相关时间段内的内存使用进度。

Further you can try to analyze a heap dump with a tool like the Eclipse Memory Analyzer (MAT). 此外,您可以尝试使用Eclipse Memory Analyzer (MAT)之类的工具来分析堆转储。 MAT has some nice reports that can help to find memory leaks. MAT有一些不错的报告,可以帮助您发现内存泄漏。 If your application's memory usage constantly grows it seems to have a leak. 如果您的应用程序的内存使用量不断增长,则似乎存在泄漏。 Otherwise it would simply have not enough memory available. 否则,它将根本没有足够的可用内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM