• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Out of Memory error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

Thanks
Ravi.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic