Java Ubuntu 内存不足错误,即使有足够的可用内存
Java OutofMemory Error in Ubuntu Even if enough memory available
我有一个 VPS 和 20GB 内存,Ubuntu OS。我正在尝试使用 JAVA_TOOL_OPTIONS 将 10GB RAM 作为最大堆分配给 java,但我不能。请参阅随附的屏幕截图。它显示可用内存为 17GB。当我尝试设置为 7GB 时,它可以正常工作。但堆错误仅在大于 7GB 时发生。我已经安装了 glassfish 并为其集群分配了 3Gb。它工作正常。但是为什么当我有 17GB 可用内存时我不能分配大于 7GB 的空间。
顶部
ULIMITS
Java-版本
过度使用内存
我的硬件是虚拟托管的。下面是配置
- 架构:x86_64
- CPU 运算模式:32 位、64 位
- 字节顺序:Little Endian
- CPU(s): 16
- 供应商 ID:GenuineIntel
- CPU 家庭:6
- 型号:26
- 步进:5
- CPU 兆赫:2266.802
- BogoMIPS:4533.60
- 虚拟化:VT-x
如果我不得不猜测,您没有 7GB 的连续 RAM 块,这看起来确实很奇怪,但在不了解您的 VM 分配的更多信息的情况下很难说。
以下是 Oracle 对此事的看法 (http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_oom):
The VM prints "OutOfMemoryError" and exits. Increasing max heap size
doesn't help. What's going on?
The Java HotSpot VM cannot expand its heap size if memory is
completely allocated and no swap space is available. This can occur,
for example, when several applications are running simultaneously.
When this happens, the VM will exit after printing a message similar
to the following.
Exception java.lang.OutOfMemoryError: requested bytes
-Xmx-Xms-Xmx
For more information, see the evaluation section of bug 4697804.
我想你可能没有交换 space。当我将 "virt" 列中的内存加起来时,它达到 40+ Gb。
Why it's taking that much swap space ? What needs to be done in order to fix this ?
嗯,根据 top
你是 运行:
- 玻璃鱼 - 9.1G
- MySQL 守护进程 - 5.4G
- 哈德逊 - 8.9G
- 连结 - 6G
- Glassfish - 6.9G(第二个实例)
和其他各种各样的东西。 "virt" 是它们的总虚拟内存占用量,其中一些将是可以共享的代码段。
目前它们大多似乎有一个小 "res"(常驻内存),这就是为什么有这么多空闲 RAM。但是,如果它们中的一些同时出现,系统对 RAM 的需求就会猛增,系统可能会开始崩溃。
我的建议是将 Hudson 和 Nexus 服务移动到单独的 VM。或者,如果那不可能,请增加交换的大小 space ... 希望您不要崩溃。
This is true. But is this a normal behaviour?
是的。
is this how memory allocation works?
是的。这确实是虚拟内存的工作原理。
I am confused with Resident memory, virtual memory and physical memory now.
与其详细解释,不如先阅读 virtual memory 上的维基百科页面。
之所以不能分配超过5G是因为privvmpages设置为5G
我们可以通过此命令“cat /proc/user_beancounters”
在 linux 中获取该信息
此外,在 VPS 中,托管服务提供商不允许我们自定义此值。我们必须使用大型虚拟服务器或专用服务器来增加此限制。
这是根本原因。然而,Stephen 和 Robin 对虚拟内存和 RES 内存的解释恰到好处。谢谢大家
我有一个 VPS 和 20GB 内存,Ubuntu OS。我正在尝试使用 JAVA_TOOL_OPTIONS 将 10GB RAM 作为最大堆分配给 java,但我不能。请参阅随附的屏幕截图。它显示可用内存为 17GB。当我尝试设置为 7GB 时,它可以正常工作。但堆错误仅在大于 7GB 时发生。我已经安装了 glassfish 并为其集群分配了 3Gb。它工作正常。但是为什么当我有 17GB 可用内存时我不能分配大于 7GB 的空间。
顶部
ULIMITS
Java-版本
过度使用内存
我的硬件是虚拟托管的。下面是配置
- 架构:x86_64
- CPU 运算模式:32 位、64 位
- 字节顺序:Little Endian
- CPU(s): 16
- 供应商 ID:GenuineIntel
- CPU 家庭:6
- 型号:26
- 步进:5
- CPU 兆赫:2266.802
- BogoMIPS:4533.60
- 虚拟化:VT-x
如果我不得不猜测,您没有 7GB 的连续 RAM 块,这看起来确实很奇怪,但在不了解您的 VM 分配的更多信息的情况下很难说。
以下是 Oracle 对此事的看法 (http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_oom):
The VM prints "OutOfMemoryError" and exits. Increasing max heap size doesn't help. What's going on?
The Java HotSpot VM cannot expand its heap size if memory is completely allocated and no swap space is available. This can occur, for example, when several applications are running simultaneously. When this happens, the VM will exit after printing a message similar to the following.
Exception java.lang.OutOfMemoryError: requested bytes
-Xmx-Xms-Xmx
For more information, see the evaluation section of bug 4697804.
我想你可能没有交换 space。当我将 "virt" 列中的内存加起来时,它达到 40+ Gb。
Why it's taking that much swap space ? What needs to be done in order to fix this ?
嗯,根据 top
你是 运行:
- 玻璃鱼 - 9.1G
- MySQL 守护进程 - 5.4G
- 哈德逊 - 8.9G
- 连结 - 6G
- Glassfish - 6.9G(第二个实例)
和其他各种各样的东西。 "virt" 是它们的总虚拟内存占用量,其中一些将是可以共享的代码段。
目前它们大多似乎有一个小 "res"(常驻内存),这就是为什么有这么多空闲 RAM。但是,如果它们中的一些同时出现,系统对 RAM 的需求就会猛增,系统可能会开始崩溃。
我的建议是将 Hudson 和 Nexus 服务移动到单独的 VM。或者,如果那不可能,请增加交换的大小 space ... 希望您不要崩溃。
This is true. But is this a normal behaviour?
是的。
is this how memory allocation works?
是的。这确实是虚拟内存的工作原理。
I am confused with Resident memory, virtual memory and physical memory now.
与其详细解释,不如先阅读 virtual memory 上的维基百科页面。
之所以不能分配超过5G是因为privvmpages设置为5G
我们可以通过此命令“cat /proc/user_beancounters”
在 linux 中获取该信息此外,在 VPS 中,托管服务提供商不允许我们自定义此值。我们必须使用大型虚拟服务器或专用服务器来增加此限制。
这是根本原因。然而,Stephen 和 Robin 对虚拟内存和 RES 内存的解释恰到好处。谢谢大家