&引用;Java运行时环境的内存不足“;eclipse中的消息

&引用;Java运行时环境的内存不足“;eclipse中的消息,java,eclipse,Java,Eclipse,在Eclipse中运行Java代码时,我得到以下消息: There is insufficient memory for the Java Runtime Environment to continue. Native memory allocation (malloc) failed to allocate 4088 bytes for AllocateHeap An error report file with more information is saved as: E:\Eclipse

在Eclipse中运行Java代码时,我得到以下消息:

There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (malloc) failed to allocate 4088 bytes for AllocateHeap
An error report file with more information is saved as:
E:\Eclipse_Workspace\BTest\hs_err_pid1888.log
我的电脑里有4GB内存。我也将我的JRE从1.7更改为1.8。但这个问题似乎没有得到解决。我使用带i3处理器的win8系统,在我的C驱动器中有大约20gb的可用磁盘空间

Eclipse版本:EclipseJuno服务发行版2

我在启动Eclipse时也收到了这条消息。我已附上错误消息屏幕截图

是什么导致了这个问题

eclipse.ini文件中的内存参数:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms40m
-Xmx512m
ulimit -a

ps -ef | wc -l
分辨率:
重新安装eclipse修复了该问题。

eclipse
安装目录中,您应该能够找到文件
eclipse.ini
。打开它并找到
-vmargs
部分。调整以下值:

-Xmx1024m

在本例中,它被设置为1GB。

您的应用程序(Eclipse)需要更多内存,而JVM分配的内存不足。您可以按照给出的答案来增加JVM分配的内存量。

上述消息意味着您在PC上运行的程序太多,没有内存再运行一个。这不是Java问题,任何Java选项都不会改变这一点

使用Windows的任务管理器查看4GB RAM中有多少是可用的。我的猜测是,在某个地方,你有一个程序,吃掉了所有的内存。找到它并杀死它

编辑您需要了解有两种类型的“内存不足”错误

第一个是OutOfMemoryException,当Java代码正在运行且Java堆不够大时,会出现该异常。这意味着Java代码向Java运行时请求内存。您可以使用
-Xmx…

另一个错误是Java运行时内存不足。这与Java堆没有任何关系。当Java请求操作系统提供更多内存时,操作系统会说:“对不起,我没有内存”,这是一个错误


要修复后者,请关闭应用程序或重新启动(以清除内存碎片)。

尝试使用以下命令修改eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms2G
-Xmx3G
-XX:MaxPermSize=2G
-XX:+UseCompressedOops
-XX:+UseParallelGC
打开eclipse后,您可以在下面进行尝试

看起来您的应用程序消耗的内存比分配的内存多(默认)。我将尝试两件事

  • 正如Harmlezz所建议的,将JVM的内存分配增加到-Xms2g-Xmx2g(如果需要,增加更多并尝试)

  • 下载eclipse内存分析器并检查导致内存泄漏的原因,甚至可以使用JConsole查看JVM内存利用率,以找出应用程序内存泄漏问题


  • 如何在运行简单命令时诊断此错误:

    java -version
    #
    # There is insufficient memory for the Java Runtime Environment to continue.
    # Cannot create GC thread. Out of system resources.
    # An error report file with more information is saved as:
    # /home2/ericlesc/code/java/c2/hs_err_pid23944.log
    
    检查您拥有的可用内存量:

    free -m
                 total       used       free     shared    buffers     cached
    Mem:         28119      26643       1475        189       2391      15368
    -/+ buffers/cache:       8884      19235
    Swap:         5117         34       5083
    
    检查用户进程的最大数量,确保没有超出限制:

    -startup
    plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
    --launcher.library
    plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
    -product
    org.eclipse.epp.package.java.product
    --launcher.defaultAction
    openFile
    --launcher.XXMaxPermSize
    256M
    -showsplash
    org.eclipse.platform
    --launcher.XXMaxPermSize
    256m
    --launcher.defaultAction
    openFile
    -vmargs
    -Dosgi.requiredJavaVersion=1.5
    -Dhelp.lucene.tokenizer=standard
    -Xms40m
    -Xmx512m
    
    ulimit -a
    
    ps -ef | wc -l
    
    对我来说,发生这种情况的原因是PHP在bluehost上消耗了太多分配给我的内存,而我能够修复它的方法是在不重新启动PHP或服务器的情况下(我不能)将
    public\u html
    目录重命名。给它一分钟让PHP看到更改,然后重新命名它

    php引擎本身存在一个bug。我找到了一个聪明的方法来快速启动PHP引擎


    (2016年2月更新)(我在这个问题上获得了大量的支持票,因为Bluehost实例PHP引擎保留了所有内存,没有留给JVM。为他们辩护,PHP正在演变成一台邪恶的rube Goldberg机器。Bluehost作为服务正在下降。

    如果您在ec2上,想要进行mvn构建,那么使用-T选项,告诉maven使用n执行生成时的线程数


    例如:
    mvn-t10 clean package

    如果您正在使用虚拟机(VM),为您的VM分配更多RAM,您的问题就会得到解决。

    您需要诊断jvm的使用情况,例如有多少进程正在运行,堆分配如何。有很多方法可以做到这一点

    • 您可以使用java jcmd检查对象数量、内存大小(对于linux,您可以使用例如“/usr/jdk1.8.0_25/bin/jcmd 19628 GC.class_histogram>/tmp/19628_ClassHistogram_1.txt”,这里19628是正在运行的应用程序进程id)。您可以轻松地检查代码中是否存在任何强引用

    我知道关于eclipse的问题,但Intellij也多次遇到类似问题,解决方法很简单。只需运行64位exe,而不是默认的32位exe。

    在我的情况下,是C:驱动器空间不足。请确保您有足够的可用空间。

    在我的情况下,它是t我手动将Windows虚拟内存设置得太低,无法在系统SSD中节省空间。

    修复起来非常简单,我不确定为什么没有人提到实际的工作解决方案

    首先,确保无线热点已关闭。这是最重要的,在构建项目时,热点不能打开


    请执行此操作,并在稍后感谢我。这是否仅在您使用eclipse时才会发生?您是否尝试在eclipse.ini(在您的eclipse文件夹中)中编辑您的eclipse jvm属性为eclipse分配更多内存?增加虚拟内存可能会解决此问题。您的系统可能受到病毒的影响。!!@Rafa El:是的,当我启动Netbeans时,我没有遇到任何此类消息。@Balaram26请求让我们知道eclipse中指定的内存参数。in?这只会增加堆。可能不会以任何方式影响windows。!!也不建议这样做。感谢您的回复。但更改后,我也会收到相同的消息。但这并不能解释为什么只有在使用eclipse时才会出现上述消息,我guess@RafaEl:上面的错误消息不是由Eclipse本身打印的。第一个错误源于内部的单元测试运行日食(所以日食可能