Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.13
-
None
Description
Getting an out of memory exception when attempting to use preflight to validate pdfs.
Env:
Linux 64 bit (arch linux)
Java 8
java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
JVM args used to test:
java -Xmx2048m -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider
PDF that is blowing up
Console output Jan 30, 2019 10:25:58 AM org.apache.pdfbox.pdmodel.font.PDType1Font <init> WARNING: Using fallback font ArialMT for base font Symbol Jan 30, 2019 10:25:58 AM org.apache.pdfbox.pdmodel.font.PDType1Font <init> WARNING: Using fallback font ArialMT for base font ZapfDingbats Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.Arrays.copyOfRange(Arrays.java:3664) at java.lang.String.<init>(String.java:207) at java.lang.StringBuilder.toString(StringBuilder.java:407) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1587) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1587) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1587) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1587) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1587) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.getDictionaryString(COSDictionary.java:1559) at org.apache.pdfbox.cos.COSDictionary.toString(COSDictionary.java:1531) at org.apache.pdfbox.preflight.xobject.XObjFormValidator.checkGroup(XObjFormValidator.java:138) at org.apache.pdfbox.preflight.xobject.XObjFormValidator.validate(XObjFormValidator.java:73) at org.apache.pdfbox.preflight.process.reflect.GraphicObjectPageValidationProcess.validate(GraphicObjectPageValidationProcess.java:74) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:84) at org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:57) at org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validateXObjects(ResourcesValidationProcess.java:224) at org.apache.pdfbox.preflight.process.reflect.ResourcesValidationProcess.validate(ResourcesValidationProcess.java:81) at org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:84)
Code used:
import java.io.File; import java.util.ArrayList; import java.util.List; import org.apache.pdfbox.preflight.PreflightDocument; import org.apache.pdfbox.preflight.ValidationResult; import org.apache.pdfbox.preflight.ValidationResult.ValidationError; import org.apache.pdfbox.preflight.parser.PreflightParser; public class Validator { private File file = null; private List<ValidationError> errorList = new ArrayList<ValidationError>(); public Validator(File file) { this.file = file; } public List<ValidationError> getErrors(){ return errorList; } public boolean validate() throws Exception{ PreflightParser parser = null; PreflightDocument document = null; ValidationResult result = null; try { parser = new PreflightParser(file); parser.parse(); document = parser.getPreflightDocument(); document.validate(); result = document.getResult(); errorList = result.getErrorsList(); } catch(Exception e) { throw e; } finally { if(document != null) { try { document.close(); }catch(Exception ignored) {} } parser = null; document = null; result = null; } return errorList.size() > 0 ? true : false; } }
Attachments
Attachments
Issue Links
- relates to
-
PDFBOX-4384 PDF/A Document Validation out of memory
- Closed
- links to