• 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

outOFMemoryException.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have 90mb xml file where i am parsing that xml using DOM ... and i am getting out of memory exception ... can anyone tell me the solution for this ??? and i cant use SAX parser for my application ...

Thanks,
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simplest solution is to increase the JVM heap size if possible. (90 MB of data must not create that much of a problem.)
You can increase the heap size by setting the following JVM parameters:

-Xms<size> (Initial heap size)
-Xmx<size> (Maximum heap size)
 
madhu Chitloore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i have tried even that : -Xmx1024mb .... its giving same error : outOfMemoryException !...


Thank you for your reply....
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"madhu cm",
Please check your private messages regarding an important administrative matter.
-Ben
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you get an out of memory exception with large settings, there is probably a conceptual error in your code.

If this was my problem I would start by inserting System.out.println() statements giving current memory use in order to find out how far the program gets. See the java.lang.Runtime JavaDocs.

Bill
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William:
If this was my problem I would start by inserting System.out.println() statements giving current memory use in order to find out how far the program gets.


At the first look i thought: "Why do i have to put system.out, wont the stack trace give me the point till where it went!"
After a minute i got the answer myself, so thought i will post the same. (Both with an intent of confirmation and sharing)
Actually, OutOfMemory error will occur when JVM is not able to allocate new memory. The stack trace will tell the line where the memory allocation failed and it is not necessay that the line before that was the one where the last memory allocation happened. So, it is very difficult to determine "till where the program went" because the last memory allocation can be anywhere in the code and may be the same line which threw the OutOfMemoryError.

You may also try taking a heap dump using jmap and then analyse it using jhat to know what objects are taking the most of heap space.
By the way, there a lot of profiling tools available like JProbe, JProfiler that will help you if you want to do an advanced profiling.
[ May 19, 2008: Message edited by: Nitesh Kant ]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that the point at which the memory exception is thrown may well have absolutely nothing to do with the part of the program that contains the conceptual error causing it to hold on to objects and waste memory. Therefore the suggestion of printing memory use statistics at various points.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic