• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 757
  • Last Modified:

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.
0
gerhardub
Asked:
gerhardub
  • 5
  • 4
  • 3
  • +1
1 Solution
 
matthew016Commented:
The Java Virtual Machine needs probably more allocated memory,

try this parameter when running your java program :

-Xmx1024M
0
 
Ajay-SinghCommented:
Your program needs more memory than default (typically 1/8 of RAM)
0
 
matthew016Commented:
e.g.

java -jar myJar.jar -Xmx1024M

you allocate here maximum 1 Go RAM

the number has to be a multiple of 1024
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Ajay-SinghCommented:
> the number has to be a multiple of 1024
Not necessarily. I am allocate a max memory of 222m as well by -Xmx222m
0
 
matthew016Commented:
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.
0
 
CEHJCommented:
>>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
0
 
gerhardubAuthor Commented:
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?
0
 
matthew016Commented:
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
0
 
gerhardubAuthor Commented:
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?
0
 
CEHJCommented:
>>
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
0
 
gerhardubAuthor Commented:
What details should I provide you?
0
 
CEHJCommented:
What the processing is, when and where it stops, etc
0
 
matthew016Commented:
Who wrote the code ?
0
 
gerhardubAuthor Commented:
The person who's having the error.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now