• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

java.lang.OutOfMemoryError error.

 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running a parsing program which opens 3 threads, each thread parses multiple files(2 files right now). I am getting java.lang.OutOfMemoryError. I am not sure why I am getting this. I am running this java parser on Windows NT with 256 MB RAM. Is it because of small memory size, am I facing this Issue. Is there any way to improve this situation. I am getting this error especially at java.io.InputStreamReader class,when I am trying to read the file.

java.lang.OutOfMemoryError
at java.io.InputStreamReader.<init>(InputStreamReader.java, Compiled Code)
at java.io.FileReader.<init>(FileReader.java, Compiled Code)
[ February 14, 2003: Message edited by: Bhasker Reddy ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strange. How big are the files you're reading? Though that should really only be an issue if you've been trying to read all the contents into memory (e.g. a really big StringBuffer, char[] array, or List of Strings).
When you say you've got 256MB - have you actually used java -Xmx to increase the maximum heap size? If not, your max memory is probably 64 MB by default. Experiment with changing this. E.g. use
java -Xmx128m MyClass
to run with max heap size 128 MB.
Does the OutOfMemoryError always come from the same line? Even if you vary the heap size? That would be particularly strange - perhaps you should show us some of the code that ends up calling the FileReader.
 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The files I am reading are 45MB. I am using
BufferedReader in = new BufferedReader(new FileReader(file)); to read the file.
I am parsing all the file and holding the data in an object.(all parsed file). It is crashing at that object level
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well then, it certainly sounds possible you'll need more than the 64 MB the JVM allocates by default. So try changing the -Xmx setting if you haven't already. Though it's strange that your program seems to error in the InputStreamReader constructor - that part doesn't seem very memory intensive.
 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the syntax of using java -Xmx128m.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming you're starting your program with something like
java MyClass
you just add the option:
java -Xmx128m MyClass
as I showed in my first post. If you don't use the "java" command directly (say, if you're using an IDE which hides it) then you may have to find the JVM configuration options on the IDE.
Documentation for the java command and its options can be found
here.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I ask what *kind* of files you are parsing and what kind of parser you are using? For instance, if you are trying to parse a 45 MB XML file with a DOM parser, you've probably generated close to 400 MB of Java objects to represent the file...this is one of the reasons I really don't like DOM...
Kyle
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic