I have a large xml database around 2 GB. I have to group elements on the basis of some attribute. As i mention in my previous mail, I tried to created a new element and embedding the element as a child element. I am getting Out of Memory because of this. If i never create a new element just using that element it is not showing any Out of Memory Error. As per my understanding is it happenning because it is creating a totally new element in the main memory itself. Please help me out. Please go through the scenario.
=== Without Any Out of Memory Error=====================
long t1=System.currentTimeMillis();
QueryProcessor pr = new QueryProcessor("let $a := //elements return $c",context);
pr.context(itr);
Iter first=pr.iter();
System.out.println(System.currentTimeMillis() - t1);
long t2=System.currentTimeMillis();
QueryProcessor pr1 = new QueryProcessor("declare variable $elements external; let $a := $elements/* return $a",context);
pr1.bind("elements",first);
Iter second=pr1.iter();
System.out.println(System.currentTimeMillis() - t2);
Scenario : 2
=== With Out of Memory Error=====================
long t1=System.currentTimeMillis();
QueryProcessor pr = new QueryProcessor("let $a := //elements return <Nelement>$c</Nelement>",context); // Here i am creating new element
pr.context(itr);
Iter first=pr.iter();
System.out.println(System.currentTimeMillis() - t1);
long t2=System.currentTimeMillis();
QueryProcessor pr1 = new QueryProcessor("declare variable $elements external; let $a := $elements/* return $a",context);
pr1.context(first);
pr1.bind("elements",first);
Iter second=pr1.iter(); // Here Out of Memory Error Comes.
System.out.println(System.currentTimeMillis() - t2);