我正面临着PDFBOX的一个大问题:我试图加载一个10Mb (test.pdf)的文件,但我需要400Mb才能在JVM上加载它:以下是代码示例:
final File mainFile = new File(
"C:/test.pdf");
System.out.println("File size: " + mainFile.length());
try {
PDDocument doc = PDDocument.load(mainFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Used Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
}这正常吗?
发布于 2012-02-25 18:35:16
不,这是不正常的。
我注意到您尚未关闭文档(必需的,请阅读documentation)。也许这是在多次运行中积累起来的。在加载文档之前,您也没有提到内存使用情况。
https://stackoverflow.com/questions/9165419
复制相似问题