Author: msahyoun
Date: Sun Feb 18 16:36:42 2018
New Revision: 1824674
URL: http://svn.apache.org/viewvc?rev=1824674&view=rev
Log:
PDFBOX-4080: add static method ScratchFile.getMainMemoryOnlyInstance(long
maxMainMemoryBytes)
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
URL:
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java?rev=1824674&r1=1824673&r2=1824674&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java Sun
Feb 18 16:36:42 2018
@@ -149,6 +149,29 @@ public class ScratchFile implements Clos
return null;
}
}
+
+ /**
+ * Getter for an instance to only use main-memory with the defined maximum.
+ *
+ * @param maxMainMemoryBytes maximum number of main-memory to be used;
+ * <code>-1</code> for no restriction;
+ * <code>0</code> will also be interpreted here
as no restriction
+ *
+ * @return instance configured to only use main memory with no size
restriction
+ */
+ public static ScratchFile getMainMemoryOnlyInstance(long
maxMainMemoryBytes)
+ {
+ try
+ {
+ return new
ScratchFile(MemoryUsageSetting.setupMainMemoryOnly(maxMainMemoryBytes));
+ }
+ catch (IOException ioe)
+ {
+ // cannot happen for main memory setup
+ LOG.error("Unexpected exception occurred creating main memory
scratch file instance: " + ioe.getMessage() );
+ return null;
+ }
+ }
/**
* Returns a new free page, either from free page pool