0

This is in a way continuation of this thread. I am developing a different Android app and ran into the "out of heap" error again. My eclipse.ini looks like this:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-vm
C:/Program Files/Java/jdk1.7.0_01/bin/javaw.exe
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xms1024m
-Xmx1024m

If I increase Xms/x values, Eclipse can't start. What else can I do to get this to work?

Thx much

trincot
  • 317,000
  • 35
  • 244
  • 286
I Z
  • 5,719
  • 19
  • 53
  • 100
  • 1
    Because you say it won't start if you increase the Xms/x ... Maybe you need physical memory, how much RAM do you have? – TryTryAgain May 15 '12 at 13:38

2 Answers2

0

If you have already increased xmx value to 1024 and you're still running into "out of heap space", you'll have to seriously think about memory leak in your application. There are several ways you can reduce memory footprint.

  • Like not creating a complex object inside a long running loop.
  • Reusing an object where possible, instead of always instantiating a new one.
  • Keeping a reference to a large object like collection or a reference to an object inside the collection, even after you are done using it.

There are tools like visualvm and jprobe to run down issues like this. If you time have take a look at this article as well.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
pacman
  • 1,061
  • 1
  • 17
  • 36
  • The app project in Eclipse is set up to let me manually select the Android device I want to run it on. It gives me the "out of heap" message even before opening up the device selection screen. Can it be that the reason for the fail is that I include several third-part JARs which combined take 11.5MB of disk space? Unfortunately, I can't really throw away any of them since the code depends on them. In which case does it mean that I am essentially at a dead end? – I Z May 15 '12 at 14:36
  • 1
    For class loading JVM uses perm-gen memory space. Try increasing that. – pacman May 15 '12 at 15:25
  • 1
    --launcher.XXMaxPermSize 1024M – pacman May 15 '12 at 15:26
  • 1
    Also make sure you are running the latest version of ADT plugin. There were some memory issues on the older version of ADT. – pacman May 15 '12 at 15:33
  • Eclipse failed to start with XXMaxPermSize > 256. – I Z May 15 '12 at 17:52
0

First, your eclipse.ini is not correct. The -vm argument should be the last thing before -vmargs.

Second, if you're trying to allocate a heap of 1MB and it fails, it's probably because of this. How much RAM does your system have? Have you tried running Eclipse with those settings without any other applications running?

Community
  • 1
  • 1
E-Riz
  • 31,431
  • 9
  • 97
  • 134
  • I am running Eclipse on a Win XP desktop with 2GB of RAM. However, I was able to run a desktop "wrapper" app that included the same external JARs plus several more without any problem. It seems that this is somehow Android-specific. – I Z May 15 '12 at 14:56
  • I think there is some confusion about where the error is coming from. Eclipse itself is running in a JVM, and it is that VM which `eclipse.ini` controls. If you're getting OOM errors from Eclipse, they're related. If, however, you are getting OOM errors from your app, while it is running, then that's a different problem (`eclipse.ini` is not involved). – E-Riz May 15 '12 at 15:19
  • Building an Android app and the rest of the features of ADT that enable running and debugging Android apps, involves more memory usage by Eclipse itself than just regular Java programs - the ADT plugins are doing lots of extra stuff. 2GB of RAM is not all that much these days, and if there are other applications running on your system it's not surprising that Eclipse's JVM can't allocate more than 1MB of heap space (see the link I posted in my answer above for an explanation). Windows' memory management is just not very good (compared to Linux or Mac OS X), you're bumping into its limitations. – E-Riz May 15 '12 at 15:21
  • I guess "I'm gonna need a bigger boat" :-) – I Z May 15 '12 at 17:54