It's 8u231
Do you see something wrong with the results?

Best regards,
Hesham

-----Original Message-----
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Tuesday, March 24, 2020 8:10 PM
To: users@pdfbox.apache.org
Subject: Re: Consumed memory after closing PDDocument

Which one? (Exact version)

I'm asking just to check that you haven't an old one, e.g. 40.

Tilman


Am 24.03.2020 um 17:26 schrieb Hesham Gneady:
> JDK 8.0
>
>
> Best regards,
> Hesham
>
> ----------------------------------------------------------------------
> ----------------------------
> Included Message:
>
> What jdk are you using?
>
> Tilman
>
> Am 24.03.2020 um 17:15 schrieb Hesham Gneady:
>> Oh! ... That's absolutely right. I am now getting right results:
>>
>> 1. Heap before Loading PDF Doc:
>> Current heap size: 265289728
>> Free heap size: 212918368
>> --------------------------------
>> 2. Heap after loading the PDF Doc:
>> Current heap size: 908066816
>> Free heap size: 342499608
>> --------------------------------
>> 3. Heap after closing the PDF Doc:
>> Current heap size: 908066816
>> Free heap size: 849820016
>> --------------------------------
>>
>>
>> Best regards,
>> Hesham
>>
>>
>> -----Original Message-----
>>
>> Memory is only freed after a GC run. You Need to invoke that explicitly.
>>
>>> Am 24.03.2020 um 14:40 schrieb Hesham Gneady <heshamgne...@gmail.com>:
>>>
>>> Hello,
>>>
>>>
>>>
>>> I am trying to make a test to see the amount of memory consumed 
>>> before and after loading a PDF file using PDFBox, and also the 
>>> consumed memory after closing the PDF file, but I've noticed that 
>>> the memory consumed after loading the PDF file is the same after 
>>> closing the PDF file. It seems that i am doing something wrong, or 
>>> that the PDF is still loaded in memory! . Here is the code I'm using:
>>>
>>>
>>>
>>> private String docPath = "c:\400mb.pdf"
>>>
>>>
>>>
>>> public void loadPDFDocument() {
>>>
>>>               printHeap( "1. Heap before Loading PDF Doc:" );
>>>
>>>
>>>
>>>               PDDocument document = null;
>>>
>>>               try {
>>>
>>>                             document = PDDocument.load(new 
>>> File(docPath));
>>>
>>>                             printHeap( "2. Heap after loading the PDF Doc:"
>>> );
>>>
>>>               } catch (IOException e) {
>>>
>>>                             throw new RuntimeException(e);
>>>
>>>               } finally {
>>>
>>>                             if (document != null) {
>>>
>>>                                          try {
>>>
>>>                                                       
>>> document.close();
>>>
>>>                                                       printHeap( "3.
>>> Heap after closing the PDF Doc:" );
>>>
>>>                                          } catch (IOException e) {
>>>
>>>                                                       
>>> e.printStackTrace();
>>>
>>>                                          }
>>>
>>>                             }
>>>
>>>               }
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>> public void printHeap( String title ) {
>>>
>>>               long heapSize = Runtime.getRuntime().totalMemory();
>>>
>>>               long heapFreeSize = Runtime.getRuntime().freeMemory();
>>>
>>>
>>>
>>>               System.out.println( title );
>>>
>>>               System.out.println( "Current heap size: " + heapSize 
>>> );
>>>
>>>               System.out.println( "Free heap size: " + heapFreeSize 
>>> );
>>>
>>>               System.out.println( "--------------------------------"
>>> );
>>>
>>> }
>>>
>>>
>>>
>>> The output for this code when calling loadPDFDocument() is:
>>>
>>> 1. Heap before Loading PDF Doc:
>>>
>>> Current heap size: 265289728
>>>
>>> Free heap size: 203194096
>>>
>>> --------------------------------
>>>
>>> 2. Heap after loading the PDF Doc:
>>>
>>> Current heap size: 899153920
>>>
>>> Free heap size: 343428432
>>>
>>> --------------------------------
>>>
>>> 3. Heap after closing the PDF Doc:
>>>
>>> Current heap size: 899153920
>>>
>>> Free heap size: 343428432
>>>
>>> --------------------------------
>>>
>>>
>>>
>>> Am I doing something wrong here?
>>>
>>>
>>>
>>>
>>>
>>> Best regards,
>>>
>>> Hesham
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
>> For additional commands, e-mail: users-h...@pdfbox.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
>> For additional commands, e-mail: users-h...@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to