内存不足,无法运行Java运行时环境以继续
我有一个带有4 GB内存的Windows操作系统。我安装了VMWare,以使用2GB RAM设置Ubuntu虚拟机。在Ubuntu中,我打开Eclipse并开始编码,Eclipse开始一次又一次地关闭,我开始出现以下错误:内存不足,无法运行Java运行时环境以继续,java,linux,eclipse,out-of-memory,heap-memory,Java,Linux,Eclipse,Out Of Memory,Heap Memory,我有一个带有4 GB内存的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 byt
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 ---------------
可供eclipse使用的内存太少。最好是用更多的ram升级您的系统
除非您有充分的理由不直接在windows下使用eclipse而不使用virtual box。如果您必须使用Ubuntu,请考虑使用Ubuntu和java和Eclipse的32位版本,或者在Windows旁边安装Ubuntu,这样您就可以引导它进入并拥有所有的内存。p> Java虚拟机进程内存不足 你可以做的事情有几种可能性。在我看来,如果您想保持流程的当前限制,以下可能性是最有希望的:
- 减小Java堆大小(
/-Xmx
):-Xms
在
中,可能有一行类似于eclipse.ini
的代码,您可以用-Xmx1024m
来代替。请尝试哪个最大堆空间仍然足以满足您的需要。确保-Xmx640m
不大于-Xms
-Xmx
- 如果且仅当您有64位系统时,您可以使用Eclipse 64位和而不是当前使用的Eclipse 32位和Java HotSpot 32位虚拟机。默认情况下,OpenJ9在内存消耗方面效率更高,还可以在这方面进行进一步调整
此处似乎给出了在64位操作系统上使用64位Java的可能性,因为64位Java虚拟机可以寻址更多内存,但是它的内存效率比等效的32位虚拟机低。你有没有尝试过错误给你的建议列表?@Shawn你能解释一下我们如何准确地执行那些将要解决的建议吗。参数以
-
开头的建议可以在eclipse.ini
下面的单独行中设置-vmargs
。其他建议涉及操作系统设置。如果你有一个64位系统,你可以使用Java HotSpot VM来代替它来减少系统上的内存负载,我从今天开始就面临这个问题。即使我也尝试重新启动虚拟机,但没有成功。请您解释一下,有没有办法用当前的系统配置来解决这个问题?给虚拟机增加半GB的ram.512MB,对吗?它会影响我的windows系统吗??当然,如果我并行使用我的系统和虚拟机,我的windows系统性能会下降。除此之外,它会以任何方式影响吗?如果这与您有关,创建一个双启动安装。事实上,我直到昨天才得到它。它对我来说很好。我只是从今天开始面临这个问题。有没有其他方法来清理ubuntu中的一些内存(我可以清理哪种类型的内存以及如何清理)…因为如果我现在增加虚拟机的RAM…将来这可能还不够,我可能会面临同样的问题…那么有没有办法清理ubuntu(虚拟机)中的一些内存??是的,我按照你的建议做了,但仍然面临同样的问题,只是将Xmx值从1024m降低到640m,但问题仍然存在?Eclipse喜欢大量内存。在2GB Linux系统上运行它有点乐观。也许需要大量的交换。@Thorbjørnravandersen作为一个Java应用程序,Eclipse占用的内存不能超过使用-Xmx
的VM提供的内存(对于大多数情况,即使Eclipse的堆空间小于640m也应该足够)。错误消息建议的解决方案之一是减少Java堆大小,而不是增加它。使用-Xmx640m
时,Java VM进程占用的空间不应超过2 GB。错误消息显示“本机内存分配(mmap)映射28311552字节失败”。28311552字节=27MB。如果将27 MB设置为VM进程的总限制,则该限制太小。否则,请告诉VM的最大内存限制,并显示eclipse.ini
文件和启动eclipse的命令。