From commits-return-11934-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Sun Feb 18 17:36:48 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A3E4B18064D for ; Sun, 18 Feb 2018 17:36:47 +0100 (CET) Received: (qmail 11077 invoked by uid 500); 18 Feb 2018 16:36:46 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 11068 invoked by uid 99); 18 Feb 2018 16:36:46 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Feb 2018 16:36:46 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id A129C3A0352 for ; Sun, 18 Feb 2018 16:36:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1824674 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java Date: Sun, 18 Feb 2018 16:36:42 -0000 To: commits@pdfbox.apache.org From: msahyoun@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180218163645.A129C3A0352@svn01-us-west.apache.org> 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; + * -1 for no restriction; + * 0 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