Eclipse + GWT -> Out of memory in development mode

2019-02-22 10:23发布

If I run my GWT application in eclipse in development mode and click around in the browser for some time, I always get an "out of memory" error in eclipse. My computer has 16 GB Ram, and there is never used more than 8GB.

I tried several config parameters. The VM-arguments in my Run configuration contain these parameters: "-Xms8192m -Xmx8192m"

Even in the eclipse.ini I tested several config parameters and now it looks like this:

--launcher.XXMaxPermSize
8192M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
8192m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms8192m
-Xmx8192m

But I still get the error. Is there any way to prevent this?

3条回答
太酷不给撩
2楼-- · 2019-02-22 10:34

If I run my GWT application in eclipse in development mode and click around in the browser for some time, I always get an "out of memory" error in eclipse.

Not exactly sure what the problem is but I do see some issues with your current arguments.

  1. You have 2 launcher args that are the same. You don't need the 2nd entry of:

    --launcher.XXMaxPermSize
    8192M
    
  2. I really doubt that you want 8g of PermSize. Something like 512m is probably much better. You can use jconsole to see how much memory is in the perm space bucket. In the below image taken from jconsole's memory tab, the bar highlighted at the bottom right shows the "Perm Gen" space. Right now it is using 26,906kb (or around 27mb). That's where code goes and it often has to be increased if you have many JSP pages which get compiled as well.

    enter image description here

    If you run your application with the following params you should be able to connect with jconsole to see how it's doing:

    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.authenticate=false
    

    I suspect that you are going to see that you are using far, far less in the "Perm Gen" space. The -Xmx8192m (or -Xmx8g) is all you need typically. It will give 8gb of memory to the heap in general which is typically short lived objects. It also scales the various different memory partitions accordingly.

For more information about various heap spaces see the Java hotspot documentation.

查看更多
趁早两清
3楼-- · 2019-02-22 10:41

put this in vm arguments in your run configurations: -Xmx2048M -XX:MaxPermSize=512m

查看更多
不美不萌又怎样
4楼-- · 2019-02-22 10:47

If the browser application is throwing the OutOfMemoryError, then you don't need to change the Eclipse settings (eclipse.ini), that's only for Eclipse itself (more memory, usually faster workbench).

To increase an app's memory (any Java app launched from Eclipse), go to the Run/Debug configurations... in the Run menu and set the VM arguments on the Arguments tab of the app's run config:

-Xms128M -Xmx1024M -XX:MaxPermSize=256M
查看更多
登录 后发表回答