简体   繁体   English

java.lang.OutOfMemoryError: 使用 itext PdfReader 读取大型 PDF 文件时超出 GC 开销限制

[英]java.lang.OutOfMemoryError: GC overhead limit exceeded when reading large PDF file using itext PdfReader

I am trying to read a pdf file using PDFReader and re-sequence of pages.我正在尝试使用 PDFReader 读取 pdf 文件并重新排序页面。 It's working with PDF with smaller size but when the size exceeds > 200MB.它与较小的 PDF 一起使用,但当大小超过 > 200MB 时。 It fails with below error它失败并出现以下错误

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at com.lowagie.text.pdf.MappedRandomAccessFile$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.lowagie.text.pdf.MappedRandomAccessFile.clean(Unknown Source)
at com.lowagie.text.pdf.MappedRandomAccessFile.close(Unknown Source)
at com.lowagie.text.pdf.RandomAccessFileOrArray.close(Unknown Source)
at com.lowagie.text.pdf.PRTokeniser.close(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readPdf(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)

I am using itext java 2.1.7 version我正在使用 itext java 2.1.7 版本

Try expanding heap memory of the running Java with -Xmx .尝试使用-Xmx扩展正在运行的 Java 的堆 memory 。

Take a look at https://alvinalexander.com/blog/post/java/java-xmx-xms-memory-heap-size-control/ to know how Xmx is used.看看https://alvinalexander.com/blog/post/java/java-xmx-xms-memory-heap-size-control/了解 Xmx 是如何使用的。

Extending the heap memory using -Xmx might help (as suggested by Pablo) but you should also look at your code and see why it produces that amount of garbage and why your code skims just below the "out of memory" mark.使用-Xmx扩展堆 memory 可能会有所帮助(正如 Pablo 所建议的那样),但您还应该查看您的代码并了解它为什么会产生这么多垃圾以及为什么您的代码略低于“内存不足”标记。 This could be the sign of broken code.这可能是代码损坏的迹象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.OutOfMemoryError:读取大文本文件时超出了GC开销限制 - java.lang.OutOfMemoryError: GC overhead limit exceeded while Reading a Large Text file java.lang.OutOfMemoryError:使用Apache POI读取Excel文件时,超出了GC开销限制 - java.lang.OutOfMemoryError: GC overhead limit exceeded" while reading excel file using apache POI java.lang.OutOfMemoryError:加载xlsx文件时,超出了GC开销限制 - java.lang.OutOfMemoryError: GC overhead limit exceeded when loading an xlsx file java.lang.OutOfMemoryError:在Web服务中加载RDF文件时,超出了GC开销限制 - java.lang.OutOfMemoryError: GC overhead limit exceeded when I load RDF file in Web Service Java PreparedStatement java.lang.OutOfMemoryError:超出了GC开销限制 - Java PreparedStatement java.lang.OutOfMemoryError: GC overhead limit exceeded 超出Junit java.lang.OutOfMemoryError GC开销限制 - Junit java.lang.OutOfMemoryError GC overhead limit exceeded 获取错误:java.lang.OutOfMemoryError:超出了GC开销限制 - Getting Error:java.lang.OutOfMemoryError: GC overhead limit exceeded 获取java.lang.OutOfMemoryError:Jboss中超出了GC开销限制 - Getting java.lang.OutOfMemoryError: GC overhead limit exceeded in Jboss java.lang.OutOfMemoryError:GC开销限制超出了excel阅读器 - java.lang.OutOfMemoryError: GC overhead limit exceeded excel reader java.lang.OutOfMemoryError(超出了GC开销限制) - java.lang.OutOfMemoryError(GC overhead limit exceeded)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM