• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic