【问题标题】:Insufficient memory to run Java Runtime environment to continue内存不足,无法运行 Java Runtime 环境继续
【发布时间】:2019-02-19 19:55:19
【问题描述】:

我有一个带有 4 GB RAM 和 Windows 操作系统的系统。我安装了 VMWare 来设置具有 2GB RAM 的 Ubuntu 虚拟机。在 Ubuntu 中,我打开 Eclipse 并开始编码,Eclipse 开始一次又一次地关闭,我开始收到以下错误:

 There is insufficient memory for the Java Runtime Environment to continue.     Native memory allocation (mmap) failed to map 28311552 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:2640), pid=4608, tid=0x6dc6eb40

 JRE version: Java(TM) SE Runtime Environment (8.0_161-b12) (build 1.8.0_161-b12)
 Java VM: Java HotSpot(TM) Client VM (25.161-b12 mixed mode linux-x86 )
 Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again


---------------  T H R E A D  ---------------

Current thread (0x099ab400):  VMThread [stack: 0x6dbee000,0x6dc6f000] [id=4629]

Stack: [0x6dbee000,0x6dc6f000],  sp=0x6dc6d240,  free space=508k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x5bffaf]  VMError::report_and_die()+0x16f
V  [libjvm.so+0x20e115]  report_vm_out_of_memory(char const*, int, unsigned int, VMErrorType, char const*)+0x55
V  [libjvm.so+0x4a2686]  os::Linux::commit_memory_impl(char*, unsigned int, bool)+0xe6
V  [libjvm.so+0x4a2afd]  os::pd_commit_memory_or_exit(char*, unsigned int, unsigned int, bool, char const*)+0x2d
V  [libjvm.so+0x49c660]  os::commit_memory_or_exit(char*, unsigned int, unsigned int, bool, char const*)+0x30
V  [libjvm.so+0x2741ad]  G1PageBasedVirtualSpace::commit_internal(unsigned int, unsigned int)+0x9d
V  [libjvm.so+0x27440c]  G1PageBasedVirtualSpace::commit(unsigned int, unsigned int)+0xfc
V  [libjvm.so+0x276a68]  G1RegionsLargerThanCommitSizeMapper::commit_regions(unsigned int, unsigned int)+0x28
V  [libjvm.so+0x2bc2ba]  HeapRegionManager::commit_regions(unsigned int, unsigned int)+0x5a
V  [libjvm.so+0x2bd343]  HeapRegionManager::make_regions_available(unsigned int, unsigned int)+0x23
V  [libjvm.so+0x2bd851]  HeapRegionManager::expand_by(unsigned int)+0xa1
V  [libjvm.so+0x250a7c]  G1CollectedHeap::expand(unsigned int)+0x11c
V  [libjvm.so+0x25b3fa]  G1CollectedHeap::do_collection_pause_at_safepoint(double)+0xd5a
V  [libjvm.so+0x5cbafe]  VM_G1IncCollectionPause::doit()+0x6e
V  [libjvm.so+0x5caad7]  VM_Operation::evaluate()+0x47
V  [libjvm.so+0x5c8ba3]  VMThread::evaluate_operation(VM_Operation*)+0xb3
V  [libjvm.so+0x5c8f40]  VMThread::loop()+0x1b0
V  [libjvm.so+0x5c93a5]  VMThread::run()+0x85
V  [libjvm.so+0x4a5219]  java_start(Thread*)+0x119
C  [libpthread.so.0+0x6295]  start_thread+0xe5

VM_Operation (0xbfbfede0): G1IncCollectionPause, mode: safepoint, requested by thread 0x0988f800

--------------  P R O C E S S  ---------------

【问题讨论】:

  • 您是否尝试过错误给您的建议列表?
  • @Shawn 你能解释一下我们如何准确地执行那些将要锻炼的建议吗?
  • 参数以-开头的建议可以在eclipse.ini下面的单独行中设置-vmargs。其他建议是指操作系统设置。如果您有 64 位系统,则可以使用 Eclipse OpenJ9 代替 Java HotSpot VM 来减少系统上的内存负载。

标签: java linux eclipse out-of-memory heap-memory


【解决方案1】:

Java 虚拟机进程内存不足

你可以做的有几种可能性。在我看来,如果您想保留当前对流程的限制,以下可能性是最有希望的:

  • 减少 Java 堆大小 (-Xmx/-Xms):
    eclipse.ini 中可能有类似 @987654325 这样的行@ 您可以替换为例如 -Xmx640m。试试哪个最大堆空间仍然足以满足您的需求。确保-Xms 不大于-Xmx
  • 当且仅当您有 64 位系统时,您可以使用 Eclipse 64 位和 Eclipse OpenJ9 而不是 Eclipse 32 位和 Java HotSpot 32 位 VM 您当前正在使用。默认情况下,OpenJ9 在内存消耗方面效率更高,也可以在这方面进一步调整。

Use 64 bit Java on a 64 bit OS 的可能性似乎在这里给出不正确,因为 64 位 Java VM 可以寻址更多内存,但内存效率低于等效的 32 位 VM。

【讨论】:

  • 是的,我按照你的建议做了,但仍然面临同样的问题,只是将 Xmx 值从 1024m 降低到 640m,但问题仍然存在?
  • Eclipse 喜欢大量内存。在 2 GB Linux 系统上运行它有点乐观。也许有很多交换。
  • @ThorbjørnRavnAndersen 作为一个 Java 应用程序,Eclipse 不能占用比带有-Xmx 的 VM 提供的更多内存(对于大多数情况,对于 Eclipse 来说,即使小于 640m 的堆空间也应该足够了)。错误消息提出的解决方案之一是减少 Java 堆大小,而不是增加它。
  • 使用-Xmx640m,Java VM 进程占用的空间不应超过 2 GB。错误消息显示“本机内存分配 (mmap) 未能映射 28311552 字节”。 28311552 字节 = 27 MB。如果将 27 MB 设置为 VM 进程的总限制,则它太小了。否则,请告知 VM 的最大内存限制,并显示 eclipse.ini 文件和启动 Eclipse 的命令。
【解决方案2】:

您的可用内存太少,无法用于 Eclipse。最好是用更多的内存升级你的系统。

除非您有充分的理由不使用虚拟框直接在 windows 下使用 eclipse。如果您必须使用 Ubuntu,请考虑使用 32 位版本的 Ubuntu、Java 和 eclipse,或者将 Ubuntu 安装在 Windows 旁边,这样您就可以启动它并拥有所有内存。

【讨论】:

  • 实际上直到昨天它还在工作,我从今天开始面临这个问题..即使我也尝试重新启动虚拟机但没有工作,你能解释一下有没有办法解决这个问题目前的系统配置?
  • 给 vm 多半 GB 的内存。
  • 512MB 对吧?无论如何它会影响我的Windows系统吗?当然,如果我并行使用我的系统和虚拟机,我的 Windows 系统性能会下降..除此之外它会以任何方式影响吗?
  • 如果您担心,请创建双引导安装。
  • 实际上我直到昨天才得到的东西对我来说工作正常我只从今天开始面临这个问题..有没有其他方法可以清理 ubuntu 中的一些内存(哪种类型的内存我可以清理以及如何清理)..因为如果我现在增加 vm 的 RAM..将来可能还不够,我可能会再次面临同样的问题..那么有什么办法可以清理 ubuntu 中的一些内存(在虚拟机中)??
猜你喜欢
  • 1970-01-01
  • 2015-11-30
  • 2017-08-13
  • 2014-02-22
  • 2020-09-03
  • 2018-02-11
  • 2018-05-20
  • 2022-10-06
  • 1970-01-01
相关资源
最近更新 更多