我看到VTD-XML parseGzip()将完整的文件加载到内存中,导致OutOfMemory。
我的Eclipse -Xms20m和-Xmx100m以及Gzipped Xml文件大小为50MB。 我正在使用的示例代码如下,任何点击以消除内存约束 VTDGen vg = new VTDGen();
isParsable = vg.parseGZIPFile(xmlFile, true);
long loadingTime = System.nanoTime();
System.out.println("read the file..");
if (isParsable) {
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("/records/record[bankbalance >100900]");
i = -1;
int j = 0;
while ((i = ap.evalXPath()) != -1) {
long l = vn.getElementFragment();
byte[] bytes = vn.getXML().getBytes();
fileOutputStream = new FileOutputStream(
"C:\\workspace\\TestFunc\\test\\out" + j + ".xml");
fileOutputStream.write(bytes, (int) l, (int) (l >> 32));
j++;
}