[jdom-interest] OutOfMemoryError
Jason Hunter
jhunter at collab.net
Sat May 19 00:15:49 PDT 2001
I found something interesting tonight. When I run the attached test on
the attached XML file (which tests average performance for a dozen build
cycles) with the latest code in CVS I get an OutOfMemoryError. I don't
see the error with beta6. Nor do I get the error when running the same
CVS code in OptimizeIt. Nor do I get the error when running the same
code in the same JVM with the JIT turned off (although it's really
slow!).
That makes me think the old documents are truly eligible for GC (because
the OptimizeIt and non-JIT engines can reclaim them) but the JDK 1.2.2
Windows JIT GC engine I'm using is being conservative. I'm wondering
what's changed since beta6 to trigger this because I'd like to change
whatever it is back!
I'm posting in case someone else might want to throw out ideas for what
might cause this. I'd also invite you to test this code with your JVM
and report your results to the list on whether it worked or not. If
other JVMs work then it'll be useful data that it's some interaction
with this JVM.
-jh-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xlink.zip
Type: application/x-zip-compressed
Size: 7167 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010519/cc37165f/xlink.bin
-------------- next part --------------
import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
public class TestBuildTime {
public static void main(String[] args) throws Exception {
long before, after;
before = System.currentTimeMillis();
Document doc = new SAXBuilder().build(args[0]);
after = System.currentTimeMillis();
System.out.println("Prime: " + (after-before));
System.gc();
before = System.currentTimeMillis();
doc = new SAXBuilder().build(args[0]);
after = System.currentTimeMillis();
System.out.println("Real: " + (after-before));
System.gc();
before = System.currentTimeMillis();
doc = new SAXBuilder().build(args[0]);
after = System.currentTimeMillis();
System.out.println("Again: " + (after-before));
before = System.currentTimeMillis();
SAXBuilder builder = new SAXBuilder();
for (int i = 0; i < 10; i++) {
doc = builder.build(args[0]);
doc = null;
System.gc();
}
after = System.currentTimeMillis();
System.out.println("Ten times reuse ave: " + ((after-before)/10));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestBuildTime.class
Type: application/octet-stream
Size: 1118 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010519/cc37165f/TestBuildTime.obj
More information about the jdom-interest
mailing list