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 ?

- 525,659
- 79
- 751
- 1,130

- 716
- 1
- 11
- 27
-
Likely you are running out of virtual memory. 64-bit OSes can give a process much more virtual memory than a 32-bit OS can. – David Schwartz Aug 06 '12 at 09:23
-
Could you paste the stack trace? I suspect you might run out of PermGen space or something similar. – keuleJ Aug 06 '12 at 10:32
-
the question is already answered, the answer of stephen and peter was very helpful. the current solution to this problem was to define vm args in the run configurations. – lunatikz Aug 06 '12 at 10:59
2 Answers
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 java
command's -Xmx
option.
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:
but i have to implement an application which will be included as a jar in another project, which is a eclipse plugin..
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? .)
-
-
thank you very much, this worked fine.. but i have to implement an application which will be included as a jar in another project, which is a eclipse plugin.. im not sure how i can ensure the explicitly usage of java -xmx option as you mentioned. is it enough to set the vm arguments in the run configurations of my project.. ? or will it be overwritten by the parent eclipse plugin, if they dont set any vm args ? – lunatikz Aug 06 '12 at 09:48
-
1@PeterLawrey - he says that, but he might be wrong. See my last paragraph. – Stephen C Aug 06 '12 at 09:50
-
+1 You could be right, he needs to check it has been set as he thinks because the default maximum for a 32-bit client JVM is fairly low. – Peter Lawrey Aug 06 '12 at 09:52
-
thanks to all of you, for the improving answers, i do understand now, what the cause for the failure is. – lunatikz Aug 06 '12 at 10:22
-
@fommil - guess what. The problem WAS that he hadn't set the -Xmx ... in the right place. – Stephen C Aug 06 '12 at 12:31
-
Not all OutOfMemoryErrors are the same. You can get an OutOfMemoryError from
- a lack of heap space
- too much GCs.
- a lack of perm gen
- a lack of stack space (to create a new thread)
- a lack of swap space
- others I have forgotten.
You need to look at the actual error and I suspect you are running out of virtual memory as you have only about 1.5 GB in total on Windows XP.
You may find reducing the maximum heap size fixes this problem as it increases the free virtual memory.
You need to check that you are really setting the maximum you think you are. On a 64-bit server JVM the defaults may be fine (In which case you never needed to set them) On a 32-bit client JVM, the defaults are fairly.

- 525,659
- 79
- 751
- 1,130
-
tried reducing the max heap size by vm args in eclipse run configurations... set it to 512mb.. application fails..set it to 1024mb application succeds...but on my linux machine im using 512mb for maximum heapsize, set in eclipse.ini and this works fine..how is this possible ? – lunatikz Aug 06 '12 at 09:56
-
I am confused, in the original question you said the 512 MB one worked and the 1024 one failed. Which machine are you talking about? – Peter Lawrey Aug 06 '12 at 09:58
-
1ok, for clarification.. winXP machine: 512 mb --> fails, 1024 mb --> succeeds... on linux: 512mb -> succeeds, but on linux the jvm args is set in the eclipse.ini and not in the run configurations, as on windows machine.. – lunatikz Aug 06 '12 at 10:03
-
The eclipse.ini sets the parameters for eclipse nothing else AFAIK. Can you set the runtime config for both systems the same way. – Peter Lawrey Aug 06 '12 at 10:26
-
1you are right, on linux there were no xmx args provided in the run configurations, thats why it worked :) Thank you very much for your answer :) – lunatikz Aug 06 '12 at 10:41