Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Facing OutOfMemoryError Java Heap Space error

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Facing OutOfMemoryError Java Heap Space error

    All,

    I am not a java developer, but I am using a java code that was available online to convert a large XML file to CSV file. The input file size is big, it is around 3GB. I got an error that it is out of memory, it is expectedly due to the large input file that i am trying to convert. Splitting of this file is not possible, could you suggest any options to work around this problem?

    This is what I ran:
    xml2csv-conv data.xml data.csv

    Error:
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at com.sun.org.apache.xerces.internal.dom.DeferredDoc umentImpl.createChu
    nk(Unknown Source)
    at com.sun.org.apache.xerces.internal.dom.DeferredDoc umentImpl.ensureCap
    acity(Unknown Source)
    at com.sun.org.apache.xerces.internal.dom.DeferredDoc umentImpl.createNod
    e(Unknown Source)
    at com.sun.org.apache.xerces.internal.dom.DeferredDoc umentImpl.createDef
    erredTextNode(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tDOMParser.characte
    rs(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImp
    l.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(U
    nknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(U
    nknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(Unknown So
    urce)
    at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(Unknown So
    urce)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(Unk
    nown Source)
    at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
    at xml2csvconv.Main.convert(Main.java:194)
    at xml2csvconv.Main.main(Main.java:493)

    Thanks a ton!

    --- Update ---

    Additional information: I am running this from a Windows8 64 bit machine with 8GB physical RAM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Facing OutOfMemoryError Java Heap Space error

    The java command has commandline options for setting the memory sizes it uses. Try using one or more of them.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Facing OutOfMemoryError Java Heap Space error

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    While splitting your input file may not be possible (feasible, desirable, whatever), how you handle the file in your program is completely under your control. Designing your program to completely (or nearly) fill the client computer's memory with data is neither good practice nor reasonable, and it increases its vulnerability to being hacked. Design your program to process the data in manageable chunks by storing the data in data structures or data bases that give you the flexibility and tools needed to access and use the data as required.

  4. #4
    Junior Member
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Facing OutOfMemoryError Java Heap Space error

    All, Thanks for your quick responses. I will go through your comments and try them. Will keep you posted

Similar Threads

  1. Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
    By venkatakrishna in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 16th, 2013, 03:16 AM
  2. java.lang.OutOfMemoryError: Java heap space
    By Nikhat in forum Exceptions
    Replies: 7
    Last Post: April 21st, 2011, 07:31 AM
  3. AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    By nasi in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 25th, 2010, 10:37 PM
  4. Replies: 15
    Last Post: February 28th, 2010, 10:30 PM
  5. OutOfMemoryError (Java heap space)
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 21st, 2009, 11:56 AM