This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Out of Memory error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Out of Memory error" Watch "Out of Memory error" New topic

Out of Memory error

Ravindra Nandyala

Joined: Jun 17, 2008
Posts: 7
Hi All,

I have written a standalone java program that fetches records from the database and calculates the checksum of each table.

The problem I am facing is with tables containing huge data sets, my program resutls in an Out of Memory error.

Below is the error that I get when I run the program with following options :

java -Xms256m -Xmx1536m DatabaseCheck.DBCheckSum

JVMDG303: JVM Requesting Java core file
JVMDG304: Java core file written to /opt/projects/gsd/java/DatabaseCheck/javacore430152.1231233966.txt
JVMDG274: Dump Handler has Processed OutOfMemory.
JVMST109: Insufficient space in Javaheap to satisfy allocation request
Exception in thread "main" java.lang.OutOfMemoryError

I have tried using setFetchSize(Integer.MIN) method to limit the number of records retrieved but this approach also does not work.

Below is sample code of my program:

If anybody can help me with this then it will be great!

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You know, each byte of a byte[] allocates exactly one byte of memory?

Can you now imagine what will happen if the byte[] contains more bytes than the JVM available memory?

Either give it more memory or buffer the bytes in an InputStream.
I agree. Here's the link:
subject: Out of Memory error
It's not a secret anymore!