发生 OutOfMemoryError :play 框架中的 Java 堆空间
我正在使用 java 创建基于游戏的 Web 应用程序。当我运行它时,出现以下错误:
Execution exception (In /app/controllers/Application.java around line 12)
OutOfMemoryError occured : Java heap space
play.exceptions.JavaExecutionException: Java heap space
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:227)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3209)
at java.lang.String.<init>(String.java:215)
at java.lang.StringBuffer.toString(StringBuffer.java:585)
at java.io.StringWriter.toString(StringWriter.java:193)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:248)
at play.templates.Template.render(Template.java:26)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:657)
at play.mvc.Controller.renderTemplate(Controller.java:637)
at play.mvc.Controller.render(Controller.java:692)
at controllers.Application.index(Application.java:12)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:540)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:498)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:474)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:469)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:157)
... 1 more
任何人知道或可能有相同的问题,请给我建议。
I am creating play-based web application with java. When I run it an error occured with the following error:
Execution exception (In /app/controllers/Application.java around line 12)
OutOfMemoryError occured : Java heap space
play.exceptions.JavaExecutionException: Java heap space
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:227)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3209)
at java.lang.String.<init>(String.java:215)
at java.lang.StringBuffer.toString(StringBuffer.java:585)
at java.io.StringWriter.toString(StringWriter.java:193)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:248)
at play.templates.Template.render(Template.java:26)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:657)
at play.mvc.Controller.renderTemplate(Controller.java:637)
at play.mvc.Controller.render(Controller.java:692)
at controllers.Application.index(Application.java:12)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:540)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:498)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:474)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:469)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:157)
... 1 more
Anybody know or maybe has the same problem, please give me advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个快速的解决方法是增加 JVM 的内存(如何完成取决于所使用的 JVM,Oracle 的 JVM 将支持
-Xmx...m
选项,其中 ... 代表最大内存内存(以兆字节为单位)。JVM 最初可能获得的内存太少,如果不是这种情况,那么检查内存使用情况应该会有所帮助,例如使用 jmap(创建堆转储)和 jhat(分析堆转储)。
A quick workaround would be to increase the memory of the JVM (how that's done depends on the JVM in use, Oracle's JVM would support the
-Xmx...m
option, where ... represents the maximum memory in megabytes).The JVM might initially get too little memory, if that's not the case then checking the memory usage should help, e.g. using jmap (create heap dumps) and jhat (analyze heap dumps).
几个月前,在 google-list 上有人指出,groovy 模板引擎的某些构造需要大量内存。我假设你也有同样的问题。
At the google-list there was a few month ago someone who pointed out that with some constructs the groovy-template engine needs a lot of memory. I assume you have the same problem.
我也偶尔会遇到这种情况。 @Thomas 的答案是一个更好的解决方案,但如果您需要快速修复,只需关闭并重新启动 Play 即可。
This happens to me occasionally too. @Thomas's answer is a better solution, but if you need a quick fix just shut down and restart Play.