Rank: Newbie
Groups: Registered
Joined: 11/9/2017(UTC) Posts: 3  Location: Portland, OR
|
During a stress test of keyword searching that uses roughly 10k words (yes, this is silly, I understand) and the memory usage rises every page searched and when I close the PDF file, the memory is not reclaimed. I can clone the PdfViewer control and dispose of it when I'm done with the file and the memory is still used. The only time the memory is reclaimed is when the application terminates. If I do not use the PdfPage.Text.Find call, I do not have memory issues, but I'm also not searching the PDF. Visual Studio Community 2015 VB.Net PDFium (current version) 3.11.3.2704 64 bit application Code:
'// tb is a textbox with search phrases per line
'// PdfViewer1 is the PDFViewer control
If PdfViewer1.Document IsNot Nothing Then
PdfViewer1.RemoveHighlightFromText()
Dim intPagesCtr = PdfViewer1.Document.Pages.Count
Dim currPage As PdfPage
For i = 0 To intPagesCtr - 1
currPage = PdfViewer1.Document.Pages(i)
Dim parts As String() = tb.Text.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
Dim found As PdfFind = Nothing
For h = 0 To parts.Count - 1
'// if the next line is commented out, there are no memory issues
found = currPage.Text.Find(parts(h), FindFlags.MatchWholeWord, 0)
If (found IsNot Nothing) Then
PdfViewer1.HighlightText(i, found.CharIndex, found.CharsCount, Color.Yellow)
Do While (found.FindNext())
PdfViewer1.HighlightText(i, found.CharIndex, found.CharsCount, Color.Yellow)
Loop
End If
Next
currPage.Dispose()
currPage = Nothing
Next
End If
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/9/2017(UTC) Posts: 3  Location: Portland, OR
|
I can't add links to the source PDF to use and text file that lists the terms as the message board thinks it's spam.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi, Try to call found.Dispose() at the end of cycle iteration.
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/9/2017(UTC) Posts: 3  Location: Portland, OR
|
Paul, In one of my previous tests I had found.dispose() call in the code and it did not change the memory usage. Below is the memory usage while PDFPage.Text.Find runs with the below code.  memusage.png (9kb) downloaded 16 time(s).Updated test code: Code:
'// tb is a textbox with search phrases per line
'// PdfViewer1 is the PDFViewer control
If PdfViewer1.Document IsNot Nothing Then
PdfViewer1.RemoveHighlightFromText()
Dim intPagesCtr = PdfViewer1.Document.Pages.Count
Dim currPage As PdfPage
For i = 0 To intPagesCtr - 1
currPage = PdfViewer1.Document.Pages(i)
Dim parts As String() = tb.Text.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
Dim found As PdfFind = Nothing
found = currPage.Text.Find(parts(h), FindFlags.MatchWholeWord, 0)
If (found IsNot Nothing) Then
PdfViewer1.HighlightText(i, found.CharIndex, found.CharsCount, color)
Do While (found.FindNext())
PdfViewer1.HighlightText(i, found.CharIndex, found.CharsCount, color)
Loop
found.Dispose()
found = Nothing
End If
Next
currPage.Dispose()
currPage = Nothing
Next
End If
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
When there is a selected or highlighted text on the page, the page is not disposed, even if it is not currently visible in the viewer.
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close