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

时间:2019-02-05 11:46:40

标签: java heap

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

由于os_commit异常失败,程序反复崩溃。

任何建议进行更新以调整Java Heap等。

#
# 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)

Redhat发布

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

1 个答案:

答案 0 :(得分:1)

您可能会受到this

的影响

根据帖子的建议解决方法:

  

这里有2种可能的解决方法

     
      
  1. 禁用压缩的Oop(-XX:-UseCompressedOops),但性能会有所下降。这将指示JVM在没有   压缩的Oops功能,它不会尝试适合Java Heap   前4GB堆
  2.   
  3. 保留CompressedOops并使用JVM选项-XX:HeapBaseMinAddress = n设置Java Heap的基础,以指定地址。   Java Heap应该从将其设置为更高的地址开始,以便在那里   足够用于本机malloc的空间
  4.