处理“java.lang.OutOfMemoryError: PermGen space” 错误
最近我在我的网络应用程序中遇到了这个错误:
java.lang.OutOfMemoryError:永久代空间
这是一个典型的在 Tomcat 6 和 JDK 1.6 上运行的 Hibernate/JPA + IceFaces/JSF 应用程序。 显然,重新部署应用程序几次后可能会发生这种情况。
是什么原因导致它以及可以采取哪些措施来避免它? 我该如何解决这个问题?
Recently I ran into this error in my web application:
java.lang.OutOfMemoryError: PermGen space
It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6.
Apparently this can occur after redeploying an application a few times.
What causes it and what can be done to avoid it?
How do I fix the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
解决方案是在 Tomcat 启动时将这些标志添加到 JVM 命令行:
您可以通过关闭 tomcat 服务,然后进入 Tomcat/bin 目录并运行 tomcat6w.exe 来完成此操作。 在“Java”选项卡下,将参数添加到“Java 选项”框中。 单击“确定”,然后重新启动服务。
如果您收到错误指定的服务不作为已安装的服务存在,您应该运行:
其中服务名称是所查看的服务器名称在 services.msc
来源:orx 对 的评论Eric 的敏捷答案。
The solution was to add these flags to JVM command line when Tomcat is started:
You can do that by shutting down the tomcat service, then going into the Tomcat/bin directory and running tomcat6w.exe. Under the "Java" tab, add the arguments to the "Java Options" box. Click "OK" and then restart the service.
If you get an error the specified service does not exist as an installed service you should run:
where servicename is the name of the server as viewed in services.msc
Source: orx's comment on Eric's Agile Answers.
您最好尝试
-XX:MaxPermSize=128M
而不是-XX:MaxPermGen=128M
。我无法说出这个内存池的具体使用情况,但它与加载到 JVM 中的类的数量有关。 (因此为 tomcat 启用类卸载可以解决该问题。)如果您的应用程序在运行时生成并编译类,则很可能需要比默认值更大的内存池。
You better try
-XX:MaxPermSize=128M
rather than-XX:MaxPermGen=128M
.I can not tell the precise use of this memory pool, but it have to do with the number of classes loaded into the JVM. (Thus enabling class unloading for tomcat can resolve the problem.) If your applications generates and compiles classes on the run it is more likely to need a memory pool bigger than the default.
多次部署后发生的应用程序服务器 PermGen 错误很可能是由容器对旧应用程序的类加载器的引用引起的。 例如,使用自定义日志级别类将导致应用程序服务器的类加载器保留引用。 您可以使用现代 (JDK6+) JVM 分析工具(例如 jmap 和 jhat)来检测这些类加载器间泄漏,以查看哪些类继续保留在您的应用程序中,并重新设计或消除它们的使用。 通常的嫌疑人是数据库、记录器和其他基础框架级库。
请参阅 类加载器泄漏:可怕的“java.lang.OutOfMemoryError: PermGen space”例外,尤其是其 后续帖子。
App server PermGen errors that happen after multiple deployments are most likely caused by references held by the container into your old apps' classloaders. For example, using a custom log level class will cause references to be held by the app server's classloader. You can detect these inter-classloader leaks by using modern (JDK6+) JVM analysis tools such as jmap and jhat to look at which classes continue to be held in your app, and redesigning or eliminating their use. Usual suspects are databases, loggers, and other base-framework-level libraries.
See Classloader leaks: the dreaded "java.lang.OutOfMemoryError: PermGen space" exception, and especially its followup post.
人们常犯的错误是认为堆空间和永久代空间是相同的,但事实并非如此。 堆中可能有大量剩余空间,但永久代中仍然可能会出现内存不足的情况。
PermGen 中 OutofMemory 的常见原因是 ClassLoader。 每当一个类被加载到 JVM 中时,它的所有元数据以及 Classloader 都保存在 PermGen 区域中,当加载它们的 Classloader 准备好进行垃圾回收时,它们将被垃圾回收。 如果类加载器存在内存泄漏,那么它加载的所有类都将保留在内存中,并且一旦重复几次就会导致 permGen 内存不足。 经典的例子是 Java.lang.OutOfMemoryError: Tomcat 中的 PermGen Space。
现在有两种方法可以解决这个问题:
1. 查找Memory Leak的原因或者是否存在内存泄漏。
2. 使用 JVM 参数
-XX:MaxPermSize
和-XX:PermSize
增加 PermGen Space 的大小。您还可以查看2 Java.lang.OutOfMemoryError的解决方案 Java 了解更多详细信息。
Common mistakes people make is thinking that heap space and permgen space are same, which is not at all true. You could have lot of space remaining in the heap but still can run out of memory in permgen.
Common causes of OutofMemory in PermGen is ClassLoader. Whenever a class is loaded into JVM, all its meta data, along with Classloader, is kept on PermGen area and they will be garbage collected when the Classloader which loaded them is ready for garbage collection. In Case Classloader has a memory leak than all classes loaded by it will remain in memory and cause permGen outofmemory once you repeat it a couple of times. The classical example is Java.lang.OutOfMemoryError:PermGen Space in Tomcat.
Now there are two ways to solve this:
1. Find the cause of Memory Leak or if there is any memory leak.
2. Increase size of PermGen Space by using JVM param
-XX:MaxPermSize
and-XX:PermSize
.You can also check 2 Solution of Java.lang.OutOfMemoryError in Java for more details.
对于 Sun JVM,使用命令行参数
-XX:MaxPermSize=128m
(显然用 128 代替您需要的任何大小)。Use the command line parameter
-XX:MaxPermSize=128m
for a Sun JVM (obviously substituting 128 for whatever size you need).尝试
-XX:MaxPermSize=256m
,如果问题仍然存在,请尝试-XX:MaxPermSize=512m
Try
-XX:MaxPermSize=256m
and if it persists, try-XX:MaxPermSize=512m
我添加
-XX: MaxPermSize = 128m
(您可以试验哪个效果最好)到VM 参数 因为我正在使用 eclipse ide。 在大多数 JVM 中,默认 PermSize 约为 64MB 如果项目中有太多类或大量字符串,则会耗尽内存。对于 Eclipse,answer 中也有描述。
第 1 步:在服务器选项卡中双击 tomcat 服务器
第 2 步:打开启动会议并将
-XX: MaxPermSize = 128m
添加到现有VM 争论的末尾< /强>。I added
-XX: MaxPermSize = 128m
(you can experiment which works best) to VM Arguments as I'm using eclipse ide. In most of JVM, default PermSize is around 64MB which runs out of memory if there are too many classes or huge number of Strings in the project.For eclipse, it is also described at answer.
STEP 1 : Double Click on the tomcat server at Servers Tab
STEP 2 : Open launch Conf and add
-XX: MaxPermSize = 128m
to the end of existing VM arguements.在部署和取消部署复杂的 Web 应用程序时,我也一直在努力解决这个问题,并认为我应该添加一个解释和我的解决方案。
当我在 Apache Tomcat 上部署应用程序时,会为该应用程序创建一个新的类加载器。 然后,类加载器用于加载应用程序的所有类,并且在取消部署时,一切都会顺利消失。 然而,实际上事情并不那么简单。
在 Web 应用程序生命周期中创建的一个或多个类拥有一个静态引用,该引用在该过程中的某个位置引用了类加载器。 由于引用最初是静态的,因此任何垃圾收集都无法清理该引用 - ClassLoader 及其加载的所有类都会保留下来。
经过几次重新部署后,我们遇到了 OutOfMemoryError。
现在这已经成为一个相当严重的问题。 我可以确保每次重新部署后都重新启动 Tomcat,但这会关闭整个服务器,而不仅仅是重新部署的应用程序,这通常是不可行的。
因此,我用代码编写了一个解决方案,该解决方案适用于 Apache Tomcat 6.0。 我没有在任何其他应用程序服务器上进行过测试,并且必须强调如果没有在任何其他应用程序服务器上进行修改,这很可能无法工作。
我还想说,我个人讨厌这段代码,并且如果可以更改现有代码以使用正确的关闭和清理方法,那么没有人应该使用它作为“快速修复”。 唯一应该使用此方法的情况是,如果您的代码依赖于一个外部库(在我的例子中,它是一个 RADIUS 客户端),但该库不提供清理其自身静态引用的方法。
无论如何,继续代码。 这应该在应用程序取消部署时调用 - 例如 servlet 的 destroy 方法或(更好的方法)ServletContextListener 的 contextDestroyed 方法。
I've been butting my head against this problem while deploying and undeploying a complex web application too, and thought I'd add an explanation and my solution.
When I deploy an application on Apache Tomcat, a new ClassLoader is created for that app. The ClassLoader is then used to load all the application's classes, and on undeploy, everything's supposed to go away nicely. However, in reality it's not quite as simple.
One or more of the classes created during the web application's life holds a static reference which, somewhere along the line, references the ClassLoader. As the reference is originally static, no amount of garbage collecting will clean this reference up - the ClassLoader, and all the classes it's loaded, are here to stay.
And after a couple of redeploys, we encounter the OutOfMemoryError.
Now this has become a fairly serious problem. I could make sure that Tomcat is restarted after each redeploy, but that takes down the entire server, rather than just the application being redeployed, which is often not feasible.
So instead I've put together a solution in code, which works on Apache Tomcat 6.0. I've not tested on any other application servers, and must stress that this is very likely not to work without modification on any other application server.
I'd also like to say that personally I hate this code, and that nobody should be using this as a "quick fix" if the existing code can be changed to use proper shutdown and cleanup methods. The only time this should be used is if there's an external library your code is dependent on (In my case, it was a RADIUS client) that doesn't provide a means to clean up its own static references.
Anyway, on with the code. This should be called at the point where the application is undeploying - such as a servlet's destroy method or (the better approach) a ServletContextListener's contextDestroyed method.
java.lang.OutOfMemoryError: PermGen
space 消息表示内存中的永久代区域已耗尽。任何 Java 应用程序都可以使用有限的内存量。 您的特定应用程序可以使用的确切内存量是在应用程序启动期间指定的。
Java 内存被分为不同的区域,如下图所示:
元空间:新的内存空间诞生
JDK 8 HotSpot JVM现在使用本机内存来表示类元数据,称为元空间; 类似于 Oracle JRockit 和 IBM JVM。
好消息是,这意味着不再有
java.lang.OutOfMemoryError: PermGen
空间问题,并且无需再使用 Java_8_Download 或更高版本。The
java.lang.OutOfMemoryError: PermGen
space message indicates that the Permanent Generation’s area in memory is exhausted.Any Java applications is allowed to use a limited amount of memory. The exact amount of memory your particular application can use is specified during application startup.
Java memory is separated into different regions which can be seen in the following image:
Metaspace: A new memory space is born
The JDK 8 HotSpot JVM is now using native memory for the representation of class metadata and is called Metaspace; similar to the Oracle JRockit and IBM JVM's.
The good news is that it means no more
java.lang.OutOfMemoryError: PermGen
space problems and no need for you to tune and monitor this memory space anymore using Java_8_Download or higher.或者,您可以切换到 JRockit,它处理 permgen 的方式与 sun 的 jvm 不同。 它通常也具有更好的性能。
http://www.oracle.com/technetwork/middleware/jrockit/overview /index.html
Alternatively, you can switch to JRockit which handling permgen differently then sun's jvm. It generally has better performance as well.
http://www.oracle.com/technetwork/middleware/jrockit/overview/index.html
1)增加PermGen内存大小
首先可以做的就是增大永久代堆空间的大小。 这不能使用通常的 –Xms(设置初始堆大小)和 –Xmx(设置最大堆大小)JVM 参数来完成,因为如上所述,永久生成堆空间与常规 Java 堆空间完全分开,
这些参数设置此常规 Java 堆空间的空间。 但是,可以使用类似的参数(至少对于 Sun/OpenJDK jvm)来增大永久生成堆的大小:
默认值为 64m。
2) 启用清理
另一种永久解决这个问题的方法是允许卸载类,这样你的 PermGen 就永远不会用完:
这样的东西在过去对我来说很神奇。 但有一件事是,使用这些会带来显着的性能权衡,因为永久扫描会为您发出的每个请求或类似的事情发出额外的 2 个请求。 您需要平衡您的使用和权衡。
您可以找到该错误的详细信息。
http://faisalbhagat.blogspot.com/2014/09/java-outofmemoryerror -permgen.html
1) Increasing the PermGen Memory Size
The first thing one can do is to make the size of the permanent generation heap space bigger. This cannot be done with the usual –Xms(set initial heap size) and –Xmx(set maximum heap size) JVM arguments, since as mentioned, the permanent generation heap space is entirely separate from the regular Java Heap space,
and these arguments set the space for this regular Java heap space. However, there are similar arguments which can be used(at least with the Sun/OpenJDK jvms) to make the size of the permanent generation heap bigger:
Default is 64m.
2) Enable Sweeping
Another way to take care of that for good is to allow classes to be unloaded so your PermGen never runs out:
Stuff like that worked magic for me in the past. One thing though, there’s a significant performance trade off in using those, since permgen sweeps will make like an extra 2 requests for every request you make or something along those lines. You’ll need to balance your use with the tradeoffs.
You can find the details of this error.
http://faisalbhagat.blogspot.com/2014/09/java-outofmemoryerror-permgen.html
我遇到了我们在这里讨论的问题,我的场景是 eclipse-helios + tomcat + jsf,您所做的是将一个简单的应用程序部署到 tomcat。 我在这里展示了同样的问题,解决如下。
在 Eclipse 中,转到服务器选项卡,双击注册的服务器(在我的情况下是 tomcat 7.0),它会打开我的文件服务器常规注册信息。 在“常规信息”部分,单击链接“打开启动配置”,这将在最后添加的 VM 参数中的“参数”选项卡中打开服务器选项的执行两个条目
并准备就绪。
I had the problem we are talking about here, my scenario is eclipse-helios + tomcat + jsf and what you were doing is making a deploy a simple application to tomcat. I was showing the same problem here, solved it as follows.
In eclipse go to servers tab double click on the registered server in my case tomcat 7.0, it opens my file server General registration information. On the section "General Information" click on the link "Open launch configuration" , this opens the execution of server options in the Arguments tab in VM arguments added in the end these two entries
and ready.
如今最简单的答案是使用 Java 8。
它不再专门为 PermGen 空间保留内存,允许 PermGen 内存与常规内存池混合。
请记住,如果您不希望 Java 8 抱怨它们不执行任何操作,则必须删除所有非标准
-XXPermGen...=...
JVM 启动参数。The simplest answer these days is to use Java 8.
It no longer reserves memory exclusively for PermGen space, allowing the PermGen memory to co-mingle with the regular memory pool.
Keep in mind that you will have to remove all non-standard
-XXPermGen...=...
JVM startup parameters if you don't want Java 8 to complain that they don't do anything.(打开一个选项卡式窗口,其中包含各种服务信息)。
在 Java 选项文本区域中添加此行:
<前><代码>-XX:MaxPermSize=128m
(a tabbed window opens with various service information).
In the Java Options text area append this line:
由于使用了大空间而不是 jvm 提供的空间来执行代码,因此发生 Perm gen space 错误。
在 UNIX 操作系统中解决此问题的最佳解决方案是更改 bash 文件上的某些配置。 以下步骤可以解决该问题。
在终端上运行命令
gedit .bashrc
。使用以下值创建
JAVA_OTPS
变量:保存 bash 文件。 在终端上运行命令 exec bash。 重新启动服务器。
我希望这种方法能够解决您的问题。 如果您使用低于 8 的 Java 版本,有时会出现此问题。 但如果你使用 Java 8,这个问题就不会出现。
Perm gen space error occurs due to the use of large space rather then jvm provided space to executed the code.
The best solution for this problem in UNIX operating systems is to change some configuration on the bash file. The following steps solve the problem.
Run command
gedit .bashrc
on terminal.Create
JAVA_OTPS
variable with following value:Save the bash file. Run command exec bash on the terminal. Restart the server.
I hope this approach will work on your problem. If you use a Java version lower than 8 this issue occurs sometimes. But if you use Java 8 the problem never occurs.
如果确实存在内存泄漏,增加永久代大小或调整 GC 参数将无济于事。 如果您的应用程序或其使用的某些第三方库泄漏了类加载器,唯一真正且永久的解决方案是找到此泄漏并修复它。 有很多工具可以帮助您,最近的一个是 Plumbr,它刚刚发布了一个新版本,其中包含所需的能力。
Increasing Permanent Generation size or tweaking GC parameters will NOT help if you have a real memory leak. If your application or some 3rd party library it uses, leaks class loaders the only real and permanent solution is to find this leak and fix it. There are number of tools that can help you, one of the recent is Plumbr, which has just released a new version with the required capabilities.
另外,如果您在 Web 应用程序中使用 log4j,请检查 log4j 文档中的此段落< /a>.
看来,如果您使用
PropertyConfigurator.configureAndWatch("log4j.properties")
,则在取消部署 Web 应用程序时会导致内存泄漏。Also if you are using log4j in your webapp, check this paragraph in log4j documentation.
It seems that if you are using
PropertyConfigurator.configureAndWatch("log4j.properties")
, you cause memory leaks when you undeploy your webapp.我有 Hibernate+Eclipse RCP 的组合,尝试使用
-XX:MaxPermSize=512m
和-XX:PermSize=512m
,它似乎对我有用。I have a combination of Hibernate+Eclipse RCP, tried using
-XX:MaxPermSize=512m
and-XX:PermSize=512m
and it seems to be working for me.设置-XX:PermSize=64m -XX:MaxPermSize=128m。 稍后您还可以尝试增加
MaxPermSize
。 希望它能起作用。 这对我来说同样有效。 仅设置 MaxPermSize 对我来说不起作用。Set
-XX:PermSize=64m -XX:MaxPermSize=128m
. Later on you may also try increasingMaxPermSize
. Hope it'll work. The same works for me. Setting onlyMaxPermSize
didn't worked for me.我尝试了几个答案,最终完成这项工作的唯一一件事是 pom 中编译器插件的配置:
希望这个有帮助。
I tried several answers and the only thing what finally did the job was this configuration for the compiler plugin in the pom:
hope this one helps.
jrockit 也为我解决了这个问题; 然而,我注意到 servlet 的重启时间要差得多,所以虽然它在生产中更好,但在开发中却是一种拖累。
jrockit resolved this for me as well; however, I noticed that the servlet restart times were much worse, so while it was better in production, it was kind of a drag in development.
内存的配置取决于您的应用程序的性质。
你在干什么?
处理的交易量是多少?
您正在加载多少数据?
等等
等等
也许
您可以分析您的应用程序并开始清理应用程序中的一些模块。
Tomcat 具有热部署功能,但会消耗内存。 尝试偶尔重新启动容器。 此外,您还需要知道在生产模式下运行所需的内存量,这似乎是进行该研究的好时机。
The configuration of the memory depends on the nature of your app.
What are you doing?
What's the amount of transactions precessed?
How much data are you loading?
etc.
etc.
etc
Probably you could profile your app and start cleaning up some modules from your app.
Tomcat has hot deploy but it consumes memory. Try restarting your container once in a while. Also you will need to know the amount of memory needed to run in production mode, this seems a good time for that research.
他们说 Tomcat 的最新版本(6.0.28 或 6.0.29)可以更好地处理重新部署 servlet 的任务。
They Say that the latest rev of Tomcat (6.0.28 or 6.0.29) handles the task of redeploying servlets much better.
我遇到了完全相同的问题,但不幸的是,所建议的解决方案都没有真正适合我。 部署的时候没有出现这个问题,我也没有做任何热部署。
就我而言,在我的网络应用程序执行期间(通过休眠)连接到数据库时,每次都会在同一点出现问题。
此链接(前面也提到过)确实提供了足够的内部信息来解决该问题。 将 jdbc-(mysql)-driver 从 WEB-INF 移出并放入 jre/lib/ext/ 文件夹似乎已经解决了问题。 这不是理想的解决方案,因为升级到较新的 JRE 需要您重新安装驱动程序。
另一种可能导致类似问题的候选者是 log4j,因此您可能也想移动该选项
I run into exactly the same problem, but unfortunately none of the suggested solutions really worked for me. The problem did not happen during deployment, and I was neither doing any hot deployments.
In my case the problem occurred every time at the same point during the execution of my web-application, while connecting (via hibernate) to the database.
This link (also mentioned earlier) did provide enough insides to resolve the problem. Moving the jdbc-(mysql)-driver out of the WEB-INF and into the jre/lib/ext/ folder seems to have solved the problem. This is not the ideal solution, since upgrading to a newer JRE would require you to reinstall the driver.
Another candidate that could cause similar problems is log4j, so you might want to move that one as well
在这种情况下,第一步是检查 GC 是否允许从 PermGen 卸载类。 标准 JVM 在这方面相当保守——类生来就是永远存在的。 因此,一旦加载,类就会保留在内存中,即使没有代码再使用它们。 当应用程序动态创建大量类并且生成的类在较长时间内不需要时,这可能会成为问题。 在这种情况下,允许 JVM 卸载类定义会很有帮助。 这可以通过在启动脚本中添加一个配置参数来实现:
默认情况下,该参数设置为 false,因此要启用此功能,您需要在 Java 选项中显式设置以下选项。 如果启用 CMSClassUnloadingEnabled,GC 也会清除 PermGen 并删除不再使用的类。 请记住,仅当使用以下选项启用 UseConcMarkSweepGC 时,此选项才有效。 因此,当运行 ParallelGC 或(上帝禁止)串行 GC 时,请确保已通过指定将 GC 设置为 CMS:
First step in such case is to check whether the GC is allowed to unload classes from PermGen. The standard JVM is rather conservative in this regard – classes are born to live forever. So once loaded, classes stay in memory even if no code is using them anymore. This can become a problem when the application creates lots of classes dynamically and the generated classes are not needed for longer periods. In such a case, allowing the JVM to unload class definitions can be helpful. This can be achieved by adding just one configuration parameter to your startup scripts:
By default this is set to false and so to enable this you need to explicitly set the following option in Java options. If you enable CMSClassUnloadingEnabled, GC will sweep PermGen too and remove classes which are no longer used. Keep in mind that this option will work only when UseConcMarkSweepGC is also enabled using the below option. So when running ParallelGC or, God forbid, Serial GC, make sure you have set your GC to CMS by specifying:
为 Tomcat 分配更多内存并不是正确的解决方案。
正确的解决方案是在销毁并重新创建上下文(热部署)后进行清理。 解决方案是阻止内存泄漏。
如果您的 Tomcat/Webapp 服务器告诉您无法取消注册驱动程序 (JDBC),则取消注册它们。 这将阻止内存泄漏。
您可以创建一个 ServletContextListener 并在 web.xml 中配置它。 这是一个 ServletContextListener 示例:
在这里您可以在 web.xml 中配置它:
Assigning Tomcat more memory is NOT the proper solution.
The correct solution is to do a cleanup after the context is destroyed and recreated (the hot deploy). The solution is to stop the memory leaks.
If your Tomcat/Webapp Server is telling you that failed to unregister drivers (JDBC), then unregister them. This will stop the memory leaks.
You can create a ServletContextListener and configure it in your web.xml. Here is a sample ServletContextListener:
And here you configure it in your web.xml:
“他们”是错误的,因为我运行的是 6.0.29,即使设置了所有选项后也有同样的问题。 正如蒂姆·霍兰上面所说,这些选择只会推迟不可避免的事情。 它们允许我在出现错误之前重新部署 3 次,而不是每次都重新部署。
"They" are wrong because I'm running 6.0.29 and have the same problem even after setting all of the options. As Tim Howland said above, these options only put off the inevitable. They allow me to redeploy 3 times before hitting the error instead of every time I redeploy.
如果你在 Eclipse IDE 中得到这个,即使在设置参数之后
--launcher.XXMaxPermSize
、-XX:MaxPermSize
等,如果您仍然遇到相同的错误,则很可能是 Eclipse 使用了有错误的 JRE 版本它可能已由某些第三方应用程序安装并设置为默认值。 这些有缺陷的版本不会获取 PermSize 参数,因此无论您设置什么,您仍然会不断收到这些内存错误。 因此,在 eclipse.ini 中添加以下参数:还要确保将 eclipse 首选项中的默认 JRE 设置为正确的 java 版本。
In case you are getting this in the eclipse IDE, even after setting the parameters
--launcher.XXMaxPermSize
,-XX:MaxPermSize
, etc, still if you are getting the same error, it most likely is that the eclipse is using a buggy version of JRE which would have been installed by some third party applications and set to default. These buggy versions do not pick up the PermSize parameters and so no matter whatever you set, you still keep getting these memory errors. So, in your eclipse.ini add the following parameters:Also make sure you set the default JRE in the preferences in the eclipse to the correct version of java.
对我来说唯一有效的方法是使用 JRockit JVM。 我有 MyEclipse 8.6。
JVM 的堆存储了正在运行的 Java 程序生成的所有对象。 Java 使用 new 运算符创建对象,新对象的内存在运行时在堆上分配。 垃圾收集是自动释放程序不再引用的对象所包含的内存的机制。
The only way that worked for me was with the JRockit JVM. I have MyEclipse 8.6.
The JVM's heap stores all the objects generated by a running Java program. Java uses the
new
operator to create objects, and memory for new objects is allocated on the heap at run time. Garbage collection is the mechanism of automatically freeing up the memory contained by the objects that are no longer referenced by the program.我有类似的问题。
我的项目是 JDK 7 + Maven 3.0.2 + Struts 2.0 + Google GUICE 依赖注入。
每当我尝试运行
mvn clean package
命令时,它都会显示以下错误并发生“BUILD FAILURE”我尝试了所有上述有用的提示和技巧,但不幸的是没有一个对我有用。
下面逐步描述了对我有用的内容:=>
元素,然后添加< argLine>
子元素,其中传递-Xmx512m -XX:MaxPermSize=256m
如下所示 =><代码><配置>
-Xmx512m -XX:MaxPermSize=256m
希望它有帮助,快乐的编程:)
I was having similar issue.
Mine is JDK 7 + Maven 3.0.2 + Struts 2.0 + Google GUICE dependency injection based project.
Whenever i tried running
mvn clean package
command, it was showing following error and "BUILD FAILURE" occuredI tried all the above useful tips and tricks but unfortunately none worked for me.
What worked for me is described step by step below :=>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
element and then<argLine>
sub element in which pass-Xmx512m -XX:MaxPermSize=256m
as shown below =><configuration>
<argLine>-Xmx512m -XX:MaxPermSize=256m</argLine>
</configuration>
Hope it helps, happy programming :)