Hi!

I have tried every possible way that I can think of
in order to reclaim memory from a created node.

Here is a very simple test case illustrating the problem:

<CODE>
import org.w3c.dom.*;
import org.apache.xerces.dom.*;

public class CloneTest3 {
    public static void main(String[] args) {
        // Make Nodes
        for (int i=0; i<=10000; i++) {
            new DocumentImpl().createTextNode("");
            if ((i%1000) == 0) {
                System.gc(); System.runFinalization();
                Runtime rt = Runtime.getRuntime();
                System.out.println("Memory usage after " + i + " empty text 
nodes: " + (rt.totalMemory()-rt.freeMemory()));
            }
        }
    }
}
</CODE>

When executing the memory for the created text nodes are never
reclaimed:

<CODE>
Memory usage after 0 clones: 2018096
Memory usage after 1000 clones: 2267040
Memory usage after 2000 clones: 2515040
Memory usage after 3000 clones: 2763040
Memory usage after 4000 clones: 3011040
Memory usage after 5000 clones: 3259040
Memory usage after 6000 clones: 3507040
Memory usage after 7000 clones: 3755040
Memory usage after 8000 clones: 4003040
Memory usage after 9000 clones: 4251040
Memory usage after 10000 clones: 4499040
</CODE>


Isn't this weird?
How can I reclaim the memory?
Are the nodes statically cached in some class?


Any help on this is very much appreciated. I am entering panic mode here. :)

Thanks,
/Christian Lizell

Reply via email to