eclipse 出现内存不足的错误,为什么?

发布于 2024-11-25 18:44:39 字数 77 浏览 1 评论 0原文

当我在“Eclipse”IDE 中创建一个新项目时。突然它显示一条警报消息“内存不足错误”。我无法确定原因。 如果有人知道原因请告诉我。

When i create a new project in "Eclipse" IDE.Suddenly it shows an alert message "Out of memory error".I cannot identify the reason.
If any one know the reason please tell me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

夜血缘 2024-12-02 18:44:39

尝试使用以下参数启动 Eclipse:

eclipse.exe -vmargs -Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m

或者根据您的要求调整这些参数

Try to start eclipse with follow paramenters:

eclipse.exe -vmargs -Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m

Or justify these parameters for your requirements

墨离汐 2024-12-02 18:44:39
  1. 转到 Eclipse 安装文件夹
  2. 如果您在 Mac OS X 上运行 Eclipse

    右键单击eclipse.app图标

    单击显示包内容

  3. 打开eclipse.ini文件

  4. 更改以下参数

    <前><代码>-Xms512m
    -Xmx3000m(希望您的开发者盒子有 >4GB 内存)

  5. 添加以下参数

    <前><代码>-XX:PermSize=256m
    -XX:MaxPermSize=512m

  1. Go to your Eclipse setup folder
  2. If you are running Eclipse on Mac OS X then

    Right click on eclipse.app icon

    Click on Show Package Contents

  3. Open eclipse.ini file

  4. Change below parameters

    -Xms512m
    -Xmx3000m (Hoping your developer box has >4GB of memory)
    
  5. Add below parameters

    -XX:PermSize=256m
    -XX:MaxPermSize=512m
    
梦幻的味道 2024-12-02 18:44:39

最明显的解释是你确实失忆了。在这种情况下,使用更大的堆启动 Eclipse 应该有助于

 -vmargs -Xmx256M

改变 256M,看看什么适合您。

如果您只有几个简单的项目,我不会期望看到这个问题。如果您正在使用其他插件,那么可以想象您需要的堆数量可能需要增加。

The most obvious explanation is that you are truly out of memory. In which case starting Eclipse with a bigger heap should help

 -vmargs -Xmx256M

varying the 256M to see what works for you.

I would not expect to see this problem if you have just a few simple projects. If you are using additional plugins then conceivably the amount of heap you need may need to be increased.

冰雪梦之恋 2024-12-02 18:44:39

不确定是否与您的问题相关,但我刚刚在使用 OpenJDK 7 的 Swing 项目中遇到了类似的问题。

经过几次启动(Run 按钮)和关闭('X'< /code> / Alt+F4) 我的应用程序,我在控制台中收到此错误:

Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:691)
    at sun.awt.AWTAutoShutdown.activateBlockerThread(AWTAutoShutdown.java:334)
    at sun.awt.AWTAutoShutdown.notifyPeerMapUpdated(AWTAutoShutdown.java:215)
    at sun.awt.AWTAutoShutdown.registerPeer(AWTAutoShutdown.java:348)
    at sun.awt.SunToolkit.targetCreatedPeer(SunToolkit.java:313)
    at sun.awt.X11.XToolkit.createFrame(XToolkit.java:410)
    at java.awt.Frame.addNotify(Frame.java:477)
    at java.awt.Window.show(Window.java:1031)
    at java.awt.Component.show(Component.java:1651)
    at java.awt.Component.setVisible(Component.java:1603)
    at java.awt.Window.setVisible(Window.java:1014)
    at tool.BAT.main(BAT.java:11)

有时,我收到另一种错误:

Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread

然后,如果我尝试再次运行它,Java 崩溃了:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000000000, pid=30388, tid=139776854689536
#
# JRE version: 7.0_07-b30
# Java VM: OpenJDK 64-Bit Server VM (23.2-b09 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  0x0000000000000000
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/mcmlxxxvi/workspace/bat/hs_err_pid30388.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
#

top 揭示了问题的原因(注意虚拟内存使用情况):

PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
30619 mcmlxxxv  20   0 3271m 390m  45m S   2.0 13.0   0:38.88 java
30667 mcmlxxxv  20   0 2172m  35m  12m S   0.3  1.2   0:01.00 java
30688 mcmlxxxv  20   0 2172m  35m  12m S   0.3  1.2   0:00.96 java
30710 mcmlxxxv  20   0 2172m  35m  12m S   0.0  1.2   0:00.97 java   

这些都是我的应用程序的实例,尚未关闭。仍然不确定为什么每个实例分配这么多虚拟内存 - 可能有一些选择。 (顺便说一句,我有 3GiB 的物理内存)。

这是我的 main() 方法:

public static void main(String[] args) {
    JFrame frame = new JFrame();
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 300);
    frame.setVisible(true);
}

我在教程中看到了注释行,并专门将其禁用以查看会发生什么。发生的情况是它默认为 HIDE_ON_CLOSE,它不会关闭和处置框架。

setDefaultCloseOperation 设置为 EXIT_ON_CLOSE 是我的解决方案。不过,有兴趣看到更多知识渊博的人对此的意见。

Not sure if relevant to your problem, but I just had a similar problem with a Swing project using OpenJDK 7.

After several cycles of starting (the Run button) and closing ('X' / Alt+F4) my application, I got this error in the console:

Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:691)
    at sun.awt.AWTAutoShutdown.activateBlockerThread(AWTAutoShutdown.java:334)
    at sun.awt.AWTAutoShutdown.notifyPeerMapUpdated(AWTAutoShutdown.java:215)
    at sun.awt.AWTAutoShutdown.registerPeer(AWTAutoShutdown.java:348)
    at sun.awt.SunToolkit.targetCreatedPeer(SunToolkit.java:313)
    at sun.awt.X11.XToolkit.createFrame(XToolkit.java:410)
    at java.awt.Frame.addNotify(Frame.java:477)
    at java.awt.Window.show(Window.java:1031)
    at java.awt.Component.show(Component.java:1651)
    at java.awt.Component.setVisible(Component.java:1603)
    at java.awt.Window.setVisible(Window.java:1014)
    at tool.BAT.main(BAT.java:11)

And sometimes, I got another sort of error:

Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread

and then, if I tried to run it once more, Java crashed:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000000000, pid=30388, tid=139776854689536
#
# JRE version: 7.0_07-b30
# Java VM: OpenJDK 64-Bit Server VM (23.2-b09 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  0x0000000000000000
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/mcmlxxxvi/workspace/bat/hs_err_pid30388.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
#

top revealed the cause of the problem (notice virtual memory usage):

PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
30619 mcmlxxxv  20   0 3271m 390m  45m S   2.0 13.0   0:38.88 java
30667 mcmlxxxv  20   0 2172m  35m  12m S   0.3  1.2   0:01.00 java
30688 mcmlxxxv  20   0 2172m  35m  12m S   0.3  1.2   0:00.96 java
30710 mcmlxxxv  20   0 2172m  35m  12m S   0.0  1.2   0:00.97 java   

These were all instances of my application, which had not been closed. Still not sure why so much virtual memory was allocated per instance - probably there's some option for that. (I have 3GiB of physical memory, by the way).

Here's my main() method:

public static void main(String[] args) {
    JFrame frame = new JFrame();
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 300);
    frame.setVisible(true);
}

I saw the commented line in a tutorial and specifically disabled it to see what would happen. What happened was that that it defaulted to HIDE_ON_CLOSE, which did not close and dispose of the frame.

Setting setDefaultCloseOperation to EXIT_ON_CLOSE was the solution for me. Interested to see input from more knowledgeable people on this, though.

羁〃客ぐ 2024-12-02 18:44:39
  • 打开您的 eclipse.ini 文件
  • XXMaxPermSize 将为 256m。
  • 将值更改为 512m。
  • 重新启动你的日食。
  • 现在您将不会在 Eclipse 中看到任何内存问题。

简要说明如下:

之前

--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m

之后:

--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
  • Open Your eclipse.ini file
  • XXMaxPermSize will be 256m.
  • Change the value to 512m.
  • Restart your eclipse.
  • Now you will not see any memory issues in Eclipse.

In Brief See below:

Before

--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m

After:

--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
无言温柔 2024-12-02 18:44:39

对于每个在没有修复它的情况下最终陷入底部的人(像我一样)...

每次我尝试保存特定文件时,我的 Eclipse 都会耗尽内存。

Eclipse 有一个错误,它无法处理方法类型和方法名称之间的注释格式,如下面给出的代码。解决方法是将评论向上或向下移动

public String 
  // Never put a comment here, Eclipse will run out of memory
  getName() {
   return "name";
  }

For everyone (like me) who ends up at the bottom without fixing it...

My Eclipse ran out of memeory every time I tried to save a specific file.

Eclipse has a bug where it is unable to handle formatting a comment between a method type and a method name, like the code given below. The fix is to move the comment up or down

public String 
  // Never put a comment here, Eclipse will run out of memory
  getName() {
   return "name";
  }
千笙结 2024-12-02 18:44:39

您必须使用 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

您可以从这里看到

You have to use setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

You can see from here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文