7 Replies Latest reply on Aug 16, 2009 8:20 PM by 3004

    heap problem parsing a XML file

      I have this problem; I must read a 10MB xml file and parse it but I got this problem at runtime:
      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
      //and other message
                      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                      DocumentBuilder db = null;
                      try {
                          db = dbf.newDocumentBuilder();
                      } catch (ParserConfigurationException e) {
                      Document doc = db.parse(file);
                      doc.getDocumentElement().normalize(); // is it necessary??                                
                      NodeList nodeLst = doc.getElementsByTagName("word");
                      for (int s = 0; s < nodeLst.getLength(); s++) { // here crashes
      I have a very long list of tag "word".
      The crach is when I try to call getLength.... How can I cope this problem.....??? Is actually here the problem or could it be in another (previous) place?