Return-Path: X-Original-To: apmail-pdfbox-dev-archive@www.apache.org Delivered-To: apmail-pdfbox-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A37FB1078D for ; Sat, 4 Jan 2014 12:12:59 +0000 (UTC) Received: (qmail 86592 invoked by uid 500); 4 Jan 2014 12:12:58 -0000 Delivered-To: apmail-pdfbox-dev-archive@pdfbox.apache.org Received: (qmail 86418 invoked by uid 500); 4 Jan 2014 12:12:54 -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 86408 invoked by uid 99); 4 Jan 2014 12:12:52 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Jan 2014 12:12:52 +0000 Date: Sat, 4 Jan 2014 12:12:52 +0000 (UTC) From: =?utf-8?Q?Andreas_Lehmk=C3=BChler_=28JIRA=29?= To: dev@pdfbox.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PDFBOX-1808) PDFTextStripper.getText - hight memory usage 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-1808?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D138= 62278#comment-13862278 ]=20 Andreas Lehmk=C3=BChler commented on PDFBOX-1808: -------------------------------------------- I'm using Java VisualVM (it's part of the jdk) as profiler. It has a lot of= monitoring features, e.g. one can see all living objects so that it is sim= ply possible to see if those can be finalized or not. In my environment all objects were released, at least after triggering the = GC. > PDFTextStripper.getText - hight memory usage > -------------------------------------------- > > Key: PDFBOX-1808 > URL: https://issues.apache.org/jira/browse/PDFBOX-1808 > Project: PDFBox > Issue Type: Bug > Components: Text extraction > Affects Versions: 1.8.2, 1.8.3 > Environment: Windows 7 > Java jdk 1.7.0_45 > Reporter: Guyenot Jeremy > Assignee: Andreas Lehmk=C3=BChler > Priority: Critical > Labels: performance > Attachments: 1808-java char copyof.jpg, 1808-java char copyofrang= e.jpg, 1808-java usage.jpg, 1808-pdfbox usage.jpg, 1808-snapshot.nps, DOSSI= ER DE CANDIDATURE_001.pdf, s5-1.png, s5-2.png, s50-1.png, s50-2.png > > Original Estimate: 72h > Remaining Estimate: 72h > > Hello, > i'm trying to extract text from pdfs but i can find that the PDFTextStrip= per use a lot of memory. > With a pdf that have 2676 pages (for a 4.6Mo size) it use 1.5Go memory. > I also constat that the memory is'nt free after the getText method is cal= led. > You can see my code bellow: > double virgule =3D Math.pow(10, 2); > =09=09System.out.println("START - Total memory (Mo): " + Math.round((Runt= ime.getRuntime().totalMemory()/1000000) * virgule) / virgule); > PDDocument cd =3D PDDocument.load(file); > =09=09System.out.println("PDDocument getNumberOfPages - Nombre de pages: = " + cd.getNumberOfPages()); > =09=09System.out.println("PDDocument load - Total memory (Mo): " + Math.r= ound((Runtime.getRuntime().totalMemory()/1000000) * virgule) / virgule); > String pdfText =3D ""; > try{ > =09PDFTextStripper stripper =3D new PDFTextStripper(); > =09pdfText =3D stripper.getText(cd); > =09=09=09System.out.println("PDFTextStripper getText - Total memory (Mo):= " + Math.round((Runtime.getRuntime().totalMemory()/1000000) * virgule) / v= irgule); > =09stripper.resetEngine(); > =09stripper =3D null; > =09=09=09System.out.println("PDFTextStripper resetEngine - Total memory (= Mo): " + Math.round((Runtime.getRuntime().totalMemory()/1000000) * virgule)= / virgule); > } > finally{ > =09if( cd!=3Dnull ){ > =09=09cd.close(); > =09=09cd =3D null; > =09=09=09=09System.out.println("PDDocument close - Total memory (Mo): " += Math.round((Runtime.getRuntime().totalMemory()/1000000) * virgule) / virgu= le); > =09} > } > retour =3D new TextField(fieldName, pdfText, Field.Store.NO); > =09=09System.out.println("TextField - Total memory (Mo): " + Math.round((= Runtime.getRuntime().totalMemory()/1000000) * virgule) / virgule); > And the result into my output window: > START - Total memory (Mo): 95.0 > PDDocument getNumberOfPages - Nombre de pages: 2676 > PDDocument load - Total memory (Mo): 121.0 > PDFTextStripper getText - Total memory (Mo): 757.0 > PDFTextStripper resetEngine - Total memory (Mo): 757.0 > PDDocument close - Total memory (Mo): 757.0 > TextField - Total memory (Mo): 757.0 > pdfText - Total memory (Mo): 757.0 > I also try to call System.gc() but the memory use is the same. -- This message was sent by Atlassian JIRA (v6.1.5#6160)