[
https://issues.apache.org/jira/browse/PDFBOX-4441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16748897#comment-16748897
]
Tilman Hausherr commented on PDFBOX-4441:
-----------------------------------------
I don't seen an issue:
- you're not using the latest version (why?);
- you are not telling whether a gc was run after the work was done so the
graphic doesn't mean anything
- you're not closing the PDDocument object in a "finally" branch (or use
try-with-resources) so maybe you're having leaks with other files
- you haven't proved that there is a memory leak.
The last one is of course tricky. You'd either have to show that a specific
object is left there after all is closed (and not one of the objects that is
kept by design, e.g. the standard 14 fonts), or at least created a scenario
where a repeated task uses up the memory.
Lets say your task is done with -Xmx100m . Create a program that does this in a
loop. If it goes on endless, then there is no memory leak. Like this:
{code:java}
public static void main(String[] args) throws IOException
{
File file = new File("sample.pdf");
String text;
int count = 0;
while (true)
{
try (PDDocument pdDocument = PDDocument.load(file,
MemoryUsageSetting.setupTempFileOnly()))
{
PDFText2HTML pdfText2HTML = new PDFText2HTML();
text = pdfText2HTML.getText(pdDocument);
}
System.out.println("count: " + count++ + ", html len: " +
text.length());
}
}
{code}
I ran that one, and it went on and on... I ended the test after over 100
iterations.
> Memory Leak Issue in case of Processing Large PDF File size > 8 MB
> ------------------------------------------------------------------
>
> Key: PDFBOX-4441
> URL: https://issues.apache.org/jira/browse/PDFBOX-4441
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 2.0.8
> Environment: Linux
> Reporter: Anshuman
> Priority: Major
> Labels: newbie
> Attachments: Screenshot 2019-01-22 08.19.53.png, sample.pdf
>
>
> *Getting Memory Leak in case of parsing Large PDFs. Memory Leakage occurring
> after processing the files i.e without any processing heap size is increasing.
> Attaching the sample file as well Heap Graph for the same.*
> *Here is my codeĀ *
> try {
> PDDocument pdDocument = PDDocument.load(file,
> MemoryUsageSetting.setupTempFileOnly());
> PDFText2HTML pdfText2HTML = new PDFText2HTML();
> fileContent = pdfText2HTML.getText(pdDocument);
> pdDocument.close();
> } catch (IOException e) {
> log.error("Exception while parsing the file:{} and the message is: ",
> file.getName(), e);
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]