开发者

OutOfMemoryError occured : Java heap space in play framework

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(Act开发者_开发知识库ionInvoker.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.


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).


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜