From dev-return-60073-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Thu Dec 6 20:59:04 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 0412C180674 for ; Thu, 6 Dec 2018 20:59:03 +0100 (CET) Received: (qmail 7738 invoked by uid 500); 6 Dec 2018 19:59:03 -0000 Mailing-List: contact dev-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 dev@pdfbox.apache.org Received: (qmail 7723 invoked by uid 99); 6 Dec 2018 19:59:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2018 19:59:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 9A4B7CC0B6 for ; Thu, 6 Dec 2018 19:59:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id SqJOZKnkwDVg for ; Thu, 6 Dec 2018 19:59:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 7403F5F23C for ; Thu, 6 Dec 2018 19:59:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id DA5A8E0115 for ; Thu, 6 Dec 2018 19:59:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 9C487252C2 for ; Thu, 6 Dec 2018 19:59:00 +0000 (UTC) Date: Thu, 6 Dec 2018 19:59:00 +0000 (UTC) From: "Ben Manes (JIRA)" To: dev@pdfbox.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (PDFBOX-4396) Memory leak due to soft reference caching MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PDFBOX-4396?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Ben Manes resolved PDFBOX-4396. ------------------------------- Resolution: Workaround > Memory leak due to soft reference caching > ----------------------------------------- > > Key: PDFBOX-4396 > URL: https://issues.apache.org/jira/browse/PDFBOX-4396 > Project: PDFBox > Issue Type: Bug > Affects Versions: 2.0.12 > Environment: JDK10; G1 > Reporter: Ben Manes > Priority: Major > Attachments: #2 - memory leak 2.png, #2 - memory leak.png, memory= leak 2.png, memory leak.png > > > In a heap dump, it appears that=C2=A0DefaultResourceCache is retaining 5.= 3 GB of memory due to buffered images (via=C2=A0PDImageXObject).=C2=A0I=C2= =A0suspect=C2=A0that G1 is not collecting soft references across all region= s before it out-of-memory errors. > In PDFBOX-4389, I discovered very slow PDDocument#load times due to a JDK= 10 I/O bug. Previously I was loading the document to render each page, but = this took 1.5 minutes. To work around that=C2=A0bug I reused the document i= nstance across pages. This seems to have fail because the pages were cached= and not=C2=A0cleared by the GC. > The=C2=A0DefaultResourceCache does not prune its cache entries when the s= oft references are collected.=C2=A0Like WeakHashMap, it should use=C2=A0a R= eferenceQueue, poll it on every access, and prune accordingly. > Thankfully=C2=A0PDDocument#setResourceCache exists. For now I am going to= reset the cache to a new instance after a page has been rendered.=C2=A0The= entries should no longer be reachable and be GC'd more aggressively. If th= at doesn't work, I'll either replace the cache (e.g. with Caffeine) or disa= ble it by setting the instance to null. > I think the desired fix is to prune the=C2=A0DefaultResourceCache and, id= eally, reconsider usage of soft references (as they tend to be poor in prac= tice).=C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org For additional commands, e-mail: dev-help@pdfbox.apache.org