eclipse with Android sdk, ERROR: Java heap space

So lately I'm having a problem while working in my apps inside eclipse the next message shows up while working with xml files:

ERROR: 'Java heap space'

I have read an try increasing inside the eclipse.ini file the:

-vmargs
-Xmx40m
-Xmx512m

to:

-vmargs
-Xmx512m
-Xmx1024m 

but it will work for a while than after and hour or so it will give me the same error, I'm working in a MacBook air with 4gb ram. I have Eclipse SDK Version: 3.7.2 Build id: M20120208-0800 and I just updated it, so I don't know if that is why is acting up this way, this is how my eclipse.ini looks right now:

-startup
../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.101.v20120109-1504
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xmx512m
-Xmx1024m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts

what else can I do to fix this? any help is really appreciated. thanks in advance.


Solution 1:

Try this

In Run->Run Configuration find the Name of the class you have been running, select it, click the Arguments tab then add:

  -Xms512M -Xmx1524M

to the VM Arguments section

Few useful links

What are the best JVM settings for Eclipse?

Error "java heap size" in Eclipse Android?

Edit:

Your eclipse.ini settings will take effect only if you change following:

Run -> External Tools -> External Tool

Configurations. go to configuration that u use, under jre tab -select option

Run in same JRE in workspace.