It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes OutOfMemmory Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "OutOfMemmory Error" Watch "OutOfMemmory Error" New topic

OutOfMemmory Error

Venkatesh Kumar
Ranch Hand

Joined: Aug 08, 2003
Posts: 68
Hi All:

I a trying to create a XML file of size ranging from 50 - 200 MB.As I read the database and start building the XML Elements I get OutOfMemmoryError.

Can anyone shed some light on the cause of this error and a way to get around it ???

Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

did you give your JVM enough memory when you started it?

java -Xmx250M
david lightman
Ranch Hand

Joined: Nov 03, 2004
Posts: 82
this is a very interesting post. I have read that a normal JVM for the appserver, let's say Websphere application server, should be set at 512MB. But if the box has lets say 6 gig of ram and your app needed to build large objects from a DB, wouldn't you need to allocate way more than 512? I mean, what if you were using connection pooling, so severeal EJBs were working concurrently on building large objects. What is the largest JVM size anyone has seen?
Senthil Somasundaram

Joined: Jun 30, 2003
Posts: 17

What is the largest JVM size anyone has seen?

This truly depends on your RAM availability and how many application server instances you have(Which shares the RAM )on that machine.

We are using 512 MB.

S Venkatesh
Ranch Hand

Joined: Jun 27, 2005
Posts: 464


This enforces GC and gives ur JVM enough space.
Please note that the values depend on your RAM size.

set JAVA_OPTIONS=-XX:NewSize=400m -XX:MaxNewSize=800m -XX:SurvivorRatio=8 -XX:MaxPermSize=300m -Xcompactgc -XX:+UseParallelGC

set MEM_ARGS=-Xms1000m -Xmx1200m

Hope this works for you.

Venkatesh S
Mayuri Roi

Joined: Oct 12, 2004
Posts: 23
We have used 2GB for JVM max heap for Websphere 6 on AIX box. Found drastic improvements in performance. Didnt notice any problems with GC.
We have 9GB physical RAM available.

Thanks.<br />Mayuri
david lightman
Ranch Hand

Joined: Nov 03, 2004
Posts: 82
I agree, if your application is basically a WAR, 256MB for the JVM may be fine. However, an EAR that contains several MDB's/EJB's that concurrently service high volume queues and make calls to a database that can return 10,000 records each that are then build in a collection and distributed back to a client would obviously need ALOT more heap. I understand why you use 2gig JVM(use EJB's too?). alot of system admins do not understand that it is the system RAM/ application that should dictate this, not a cookie cutter standard.
We had severall issues on a prototype, yes getting the infamous outOfMemory exception, and we are currently workig towards:
-raising the JVM heap to at least 1.5 gig
-clustering WAS instances allowing us to lower the number of connection pools for the MDB's/ stateless Session bean(that use MQ) and JDBC pool Intern cluster

it takes alot of performance testing and probr moitoring to configure this

any thoughts?
I agree. Here's the link:
subject: OutOfMemmory Error
It's not a secret anymore!