[jdom-interest] out of memory while processing large xml files

John Hurst jbhurst at attglobal.net
Fri Jan 19 14:30:21 PST 2001


Have you tried increasing the heap size for your Java VM?

With the Sun JVM, the non-standard options -Xms and -Xmx can be used to override the initial and maximum heap sizes -- try java -X to find out about these options. I believe that the default sizes are small enough that you could get problems when dealing with a number of 20MB objects.

John Hurst


----- Original Message ----- 
From: prakash ivb 
To: jdom-interest at jdom.org 
Sent: Saturday, January 20, 2001 9:18 AM
Subject: [jdom-interest] out of memory while processing large xml files


hai,

              i am trying to parse multiple xml files with each file of 20M
size and i am getting out of memory error. is there any way i can solve my
problem. the code is given below:


import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.JDOMException;

class extn implements FilenameFilter {
  String ext;
  public extn (String ext) {
    this.ext = "." + ext;
  }
  public boolean accept(File dir, String name) {
    return name.endsWith(ext);
  }
}

public class JdomParser {
  
  public static void main(String args[]) {
    if (args.length !=1) {
       System.out.println("Usage: JdomParser [filename to parse]");
       return;
     }
     try {
    String dirname = "n:"+File.separator+"data"+File.separator + args[0] +
File.separator+ "rawdata";
   File f = new File(dirname);
    FilenameFilter files = new extn("xml");
    String s3[] = f.list(files);
    int ct = 1;
       System.out.println("Parsing Begins at " + d + "\n");
       for (int k=0; k<s3.length;k++) {
         SAXBuilder builder = new SAXBuilder(false);
Document doc =  builder.build(new File(f, s3[k]));
System.out.println("Parsing File:  " + s3[k] + "\n"); 
       Element root = doc.getRootElement();
       List node = root.getChild("Collection")
                        .getChild("Iteration")
                        .getChildren("Device");
      
       Iterator i = node.iterator();
       while (i.hasNext()) {
         Element elem = (Element)i.next();
       String s = elem.getChild("Node")
               .getText();
         System.out.println("Parsing No. " + ct + "   Node: " + s + "\n");
        List command = elem.getChildren("Command");
         Iterator j = command.iterator();
         System.out.println("    Parsing Commands... \n");
         int ct1 = 1;
         while (j.hasNext()) {
           Element comelem = (Element)j.next();
           String s1 = comelem.getChild("Command_String").getText();
           String s2 = comelem.getChild("Command_Data").getText();
           System.out.println("    " +ct1 +" : " + s1 + "\n");
           System.out.println("        Parsing Command Data...\n");
           ct1++;
         }
       ct++;
       }
       System.out.println("Document " + s3[k] + " successfully parsed\n");
       ct = 1;
     }
             
     } catch (JDOMException e) {
        System.out.println( "ERROR: " + e.getMessage());
       }
   }
   
}
i will appreciate you help.


prakash Inuganti



____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20010120/bb74914d/attachment.htm


More information about the jdom-interest mailing list