i got an strange issue with outOfMemory errors.
i had written a application, which have in some parts heavy memory usage.
on my laptop (linux, 64bit, eclipse indigo, vmargs: xms:40, xmx:512, 4gb physical ram) the application runs without any problem..
on another pc (WinXP SP3, 32bit, eclipse juno, vmargs: xms:40, xmx:1024(!), 2gb physical ram) the application terminates with the stated error in title.
both machines are using the java 7 jdk of oracle.
how is this possible, that the application fails on the another pc, which has more heap space, than my laptop.
i developed the application on my laptop… but i think this should not be the cause for this error, right ?
i got an strange issue with outOfMemory errors. i had written a application, which
Share
The 32 and 64 bit versions of Hotspot Java have different policies about how to determine the default maximum size for the heap. On 32 bit JVMs, a fixed default heap size is used. On 64 bit JVMs, the heap size depends on the amount of physical memory on the system.
The solution is to set the maximum heap size explicitly using the
javacommand’s-Xmxoption.In your case you are already using the -Xmx argument, and (apparently) you are using a larger value on the 32 bit platform … and the 32 bit version is dying first! I can think of a number of possible explanations (in decreasing likelihood):
Your 32bit machine doesn’t have enough swap space, and cannot meet the JVM’s request for more memory when it tries to grow the heap.
Your application is figuring out how much memory is available and adjusting its behaviour accordingly … but is getting it wrong in the large memory case.
There is some difference in the input to the application in the two scenarios, and that is causing the problem.
The application is using memory mapped files (or something else like that) which are using up a significant proportion of your address space … reducing the address space available for the heap. On a 64 bit machine, you have many gigabytes of address space, but on a 32 bit Windows XP machine your application’s address space will be limited to ~2Gb by the OS and the instruction set / hardware architecture.
(Your changing description of the problem is not helping …)
If you are launching the application from Eclipse, it is possible that you are confusing the -Xmx setting used by the Eclipse JVM with the -Xmx setting used by the JVM that runs your application. If you don’t set the -Xmx options explicitly in the application’s launcher configuration … it will use the default heap size!!
In response to your comment:
For an Eclipse plugin, the JVM size is determined by the parent Eclipse. Your plugin has no say in the matter. If your plugin requires a lot of heap space, you need to get the user to adjust the Eclipse heap parameters by hand.
If you are launching that Eclipse instance from another Eclipse instance … I’m not sure if the application launcher parameters would have any effect. But this should only matter to you (and others) who are developing your plugin.
(In the case of an executable JAR file, it is not possible to specify the heap size in the JAR manifest. But there are other options – see Can I set Java max heap size for running from a jar file? .)