如何防止Netbeans中的PermGen空间错误? [英] How can I prevent PermGen space errors in Netbeans?

查看:136
本文介绍了如何防止Netbeans中的PermGen空间错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每隔15-30分钟Netbeans会显示一个 java.lang.OutOfMemoryError:PermGen space 。根据我从谷歌学到的东西,这似乎与类加载器泄漏或内存泄漏有关。

Every 15-30 minutes Netbeans shows a "java.lang.OutOfMemoryError: PermGen space". From what I learned from Google this seems to be related to classloader leaks or memory leaks in general.

不幸的是我找到的所有建议都与应用程序服务器有关,我不知道将它们改编为Netbeans。 (我甚至不确定它是同一个问题)

Unfortunately all suggestions I found were related to application servers and I have no idea to adapted them to Netbeans. (I'm not even sure it's the same problem)

我的申请中是否有问题?我如何找到源?

Is it a problem in my application? How can I find the source?

推荐答案

这是因为常量类加载。

Java在永久堆中存储类字节代码和所有常量(例如字符串常量),默认情况下不是垃圾回收(这在大多数情况下都有意义,因为类在应用程序的生命周期中只加载一次) 。

Java stores class byte code and all the constants (e.g. string constants) in permanent heap that is not garbage collected by default (which make sense in majority of situations because classes are loaded only once during the lifetime of an application).

在整个生命周期中经常加载类的应用程序:

In applications that often load classes during an entire lifetime that are:


  • 热重新部署期间的Web和应用程序服务器;

  • 运行已开发的应用程序时的IDE(每次在Netbeans中运行Run按钮或eclipse时,它会将应用程序的类加载一个新的);

  • etc
    这种行为是不正确的,因为堆最终会填满。

你需要打开永久堆垃圾收集以防止此错误。

You need to turn on permanent heap garbage collection to prevent this error.

我使用选项

-XX:MaxPermSize=256M
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled

(停止我的eclipse 3.4抛出 java.lang.OutOfMemoryError:PermGen space 所以它也适用于netbeans)。

(stopped my eclipse 3.4 from throwing "java.lang.OutOfMemoryError: PermGen space" so it should also work with netbeans).

编辑:请注意,对于Netbeans,您可以在以下位置设置这些选项:
[Netbeans安装] \ etcc \ netbeans.conf
您应该在 -J 前面添加这些选项,并将它们添加到 netbeans_default_options 中(参见<$ c中的注释) $ c> netbeans.conf 获取更多信息。)

Edit: Just note that for Netbeans you set those options in: [Netbeans installation]\etc\netbeans.conf You should prefixe those options with -J and add them in netbeans_default_options (see comments in netbeans.conf for more informations).

这篇关于如何防止Netbeans中的PermGen空间错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆