码头7:OutOfMemoryError:重新部署应用程序上的PermGen空间 [英] Jetty 7: OutOfMemoryError: PermGen space on application redeploy

查看:169
本文介绍了码头7:OutOfMemoryError:重新部署应用程序上的PermGen空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首次应用正确启动.然后,我删除webapp/*.war文件并粘贴* .war的新版本.码头开始部署新战争,但发生错误java.lang.OutOfMemoryError: PermGen space.如何配置Jetty来修复错误/进行正确的重新部署?

First time app starts correctly. Then I delete webapp/*.war file and paste new version of *.war. Jetty start deploying new war but error java.lang.OutOfMemoryError: PermGen space occurs. How can I configure Jetty to fix error / make correct redeploy?

解决方案对我没有帮助.
码头版本:jetty-7.4.3.v20110701

This solution doesn't help me.
Jetty version: jetty-7.4.3.v20110701

推荐答案

可能无法解决此问题.每个JVM都有一个PermGen内存区域,用于存储类和静态数据.每当您的应用程序取消部署时,它的类加载器都将被丢弃,所有类也将被其加载.如果由于仍然存在对类加载器的其他引用而导致操作失败,则垃圾回收类加载器和您的应用程序类也将失败.

There is probably no way to configure the problem away. Each JVM has one PermGen memory area that is used for class loading and static data. Whenever your application gets undeployed its classloader should be discarded and all classes loaded by it as well. When this fails because other references to the classloader still exist, garbage collecting the classloader and your applications classes will also fail.

博客条目其后续操作解释了问题.每当应用程序容器的代码使用包含对您的一个类的引用的类时,将防止对类进行垃圾回收.提到的博客条目中的示例是java.util.logging.Level构造函数:

A blog entry and its follow up explain a possible source of the problem. Whenever the application container's code uses a class that holds a reference to one of your classes, garbage collection of your classes is prevented. The example from the mentioned blog entry is the java.util.logging.Level constructor:

protected Level(String name, int value) {
    this.name = name;
    this.value = value;
    synchronized (Level.class) {
        known.add(this);
    }
}

请注意,knownjava.util.logging.Level的静态成员.构造函数存储对所有创建的实例的引用.因此,一旦Level类被加载或从应用程序的代码中实例化后,垃圾回收将无法删除您的类.

Note that known is a static member of java.util.logging.Level. The constructor stores a reference to all created instances. So as soon as the Level class was loaded or instantiated from outwith your application's code, garbage collection can't remove your classes.

要解决该问题,您可以避免使用所有与您自己的代码无关的类,或者确保没有任何引用因您的代码超出对您的类的保留.这两个问题都可能在Java附带的任何类中发生,因此无法在应用程序中修复.您无法通过仅更改自己的代码来防止此问题!

To solve the problem you could avoid all classes that are in use outwith your own code or ensure no references are held to your classes from outwith your code. Both problems could occur within any class delivered with Java and are thus not feasible to be fixed within your application. You cannot prevent the problem by altering only your own code!

您的选择基本上是:

  • 增加内存限制,减少错误发生的频率
  • 按照链接的博客文章中的详细信息分析您的代码,并避免使用存储对您的对象的引用的类

这篇关于码头7:OutOfMemoryError:重新部署应用程序上的PermGen空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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