DOM heap memory problem and Text element question

Hi All,

I have to parse LOADS (about 3000) of small XML (6k) files and have been using DOM parser... Unfortunately i get a Java Heap out of memory error and i dont know how to solve it... i know i can increase my memory usage but thats only a temporary solution and i was hoping for a better solution. The error occurs on this line:document = builder.parse(fil);

try{

File fil=null;

DocumentBuilder builder =null;

builder = factory.newDocumentBuilder();

for(int i=0;i<str.length;i++){

fil=new File(str[i]);

document[i] = builder.parse(fil);

fil=null;

System.gc();

}

}catch (Exception sxe){sxe.printStackTrace();}

can you suggest anything?

the second probably simpler question that i have is: what constitutes a Text element i.e. which standard tags are assumed to be Text elements?

Thanks for your help

Message was edited by:

Lila_harr

Message was edited by:

Lila_harr>

[1431 byte] By [Lila_harra] at [2007-11-27 3:06:10]
# 1
Simply: do what you need to do with each document after you parse it, and don't keep the references to previous ones.Don't, if you can help it, load all your data and then process it. Load and process in chunks.
malcolmmca at 2007-7-12 3:52:19 > top of Java-index,Java Essentials,Java Programming...
# 2
perfect! that worked thank you very very much!!
Lila_harra at 2007-7-12 3:52:19 > top of Java-index,Java Essentials,Java Programming...