Link to home
Start Free TrialLog in
Avatar of gerhardub
gerhardub

asked on

Java Error under Linux: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space...

I've got a developer who is having a problem with Java running on RedHat EL 4 WS with the Sun JDK installed.

When she attempts to run the code, she gets this error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

What are the likely causes of this?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of matthew016
matthew016
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ajay-Singh
Ajay-Singh

Your program needs more memory than default (typically 1/8 of RAM)
e.g.

java -jar myJar.jar -Xmx1024M

you allocate here maximum 1 Go RAM

the number has to be a multiple of 1024
> the number has to be a multiple of 1024
Not necessarily. I am allocate a max memory of 222m as well by -Xmx222m
Ok I see,

I had this information here :  http://edocs.bea.com/wls/docs61/perform/JVMTuning.html

Anyway on this site, Chapter "Java Heap Size Options",

you have the other options available.
Avatar of CEHJ
>>What are the likely causes of this?

How and when does it happen?
It's not necessarily the case, but it could be the sign of something wrong, such as runaway loops or recursion
Avatar of gerhardub

ASKER

Ok folks, so she bumped the memory up to -Xmx8128M  (8GB - 1/2 the RAM in the workstation), and the memory error went away.

BUT: She says the code just stops running in the middle, and that there is nothing in the log file.  She can continue the processing where is stops, but it's sorta annoying.

Thoughts?
Did she wrote the code ?

8 Go is a lot of memory ! maybe like CEHJ said it's a part of code not written properly which stops the process and making it consuming a lot of ressources.

Otherwise I have no idea without further details
The machine is a 16GB - 4 Processor workstation...

Where would I get the further details?  Are there logs and so on that I might be able to provide you guys?
>>
BUT: She says the code just stops running in the middle, and that there is nothing in the log file.  She can continue the processing where is stops, but it's sorta annoying.
>>

Difficult to know without more detail
What details should I provide you?
What the processing is, when and where it stops, etc
Who wrote the code ?
The person who's having the error.