Java程序无法映射本地内存分配

3

即使有足够的RAM可用,Java程序仍无法分配本机内存。

程序在失败后重复崩溃,并出现os_commit异常。

建议更新以调整Java堆等设置。

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 12288 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Use 64 bit Java on a 64 bit OS
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2627), pid=35462, tid=140393234093824
#
# JRE version: Java(TM) SE Runtime Environment (8.0_65-b17) (build 1.8.0_65-b17)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.65-b01 mixed mode linux-amd64 compressed oops)
# Core dump written. Default location: /usr/hdp/share/hst/activity-analyzer/core or core.35462
#

根据日志,您可以看到有足够的可用内存。

Memory: 4k page, physical 264266920k(135968600k free), swap 8393468k(8393468k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (25.65-b01) for linux-amd64 JRE (1.8.0_65-b17), built on Oct  6 2015 17:16:12 by "java_re" with gcc 4.3.0 20080428 (Red Hat 4.3.0-8)

time: Tue Feb  5 05:54:26 2019
elapsed time: 2928 seconds (0d 0h 48m 48s)

资源利用率

# free -mg
             total       used       free     shared    buffers     cached
Mem:           252        134        117          0          0         25
-/+ buffers/cache:        108        143
Swap:            8          0          8

JMap 输出
# jmap -heap 2820
Attaching to process ID 2820, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.65-b01

using thread-local object allocation.
Parallel GC with 33 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 0
   MaxHeapFreeRatio         = 100
   MaxHeapSize              = 33554432000 (32000.0MB)
   NewSize                  = 44564480 (42.5MB)
   MaxNewSize               = 11184635904 (10666.5MB)
   OldSize                  = 89653248 (85.5MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 9320267776 (8888.5MB)
   used     = 7558977896 (7208.803077697754MB)
   free     = 1761289880 (1679.696922302246MB)
   81.10258286209995% used
From Space:
   capacity = 262668288 (250.5MB)
   used     = 242645032 (231.40433502197266MB)
   free     = 20023256 (19.095664978027344MB)
   92.37698004869168% used
To Space:
   capacity = 346030080 (330.0MB)
   used     = 0 (0.0MB)
   free     = 346030080 (330.0MB)
   0.0% used
PS Old Generation
   capacity = 715653120 (682.5MB)
   used     = 395523640 (377.2007369995117MB)
   free     = 320129480 (305.2992630004883MB)
   55.267507252675706% used

22626 interned Strings occupying 2218928 bytes.

Java 版本

# java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

红帽发行版

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)

2
你使用了哪些JVM参数?你使用的操作系统和架构是什么? - Lino
你使用的是哪个JRE? - m0skit0
更新了帖子。 - Shahrukh Khan
有人知道为什么会显示“在32位模式下,进程大小限制已达到”,但是当指定VM版本时却表明您正在使用64位服务器(“Java VM:Java HotSpot(TM) 64-Bit Server”)吗?这些消息似乎矛盾。我也遇到了同样的问题,使用Java 8.0_181-b13,字节数完全相同(12288)。 - theyuv
1个回答

4
您可能受到此问题的影响:这里 根据帖子中提出的建议,有两种可能的解决方法:

这里有两种可能的解决方案:

  1. 禁用压缩指针(-XX:-UseCompressedOops),但会略微降低性能。这将指示JVM在没有压缩指针功能的情况下运行,并且不会尝试将Java堆适配到前4GB的堆中。
  2. 保持压缩指针并使用JVM选项-XX:HeapBaseMinAddress=n设置Java堆的基地址,以指定Java堆应从哪个地址开始,将其设置为更高的地址,以便为本机malloc腾出足够的空间。

谢谢。这个 bug 是针对 8u131 版本的。OP 正在使用不同的版本。这还与我正在使用的版本有关吗? - theyuv

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接