logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kmeier  
#1 Posted : Tuesday, May 16, 2023 1:16:20 PM(UTC)
kmeier

Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 2
United States
Location: NH

Hello!

So below I have a accessor method called "DefaultSetMetadata". When the Get is called, it returns the current page information that I then use to update and display in the UI. I am using a pdf file that is 500k documents but I believe the size of the job doesn't matter. I seem to have a memory leak that is something like 2MB a second and when run overnight, will take up 70GB. If I make this method return an empty dictionary, the leak goes away. I have tried the C# Using statement and also explicit Dispose(). I notice that if I call IsDispose() after the Using statement, it returns false. Any advice or is this a known bug?

FYI, I load the PdfDoc in another method like this:
pdfStream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
PdfDoc = PdfDocument.Load(pdfStream);


Code:

public Dictionary<string, string> DefaultSetMetadata
{
    get
    {
        try
        {
            if (PdfDoc == null)
            {
                return null;
            }

            defaultMetadata.Clear();


            using PdfTypeDictionary PieceInfoDictionary = PdfDoc.Pages[(DocumentNumber * DocumentSize) - 1].Dictionary.GetBy("PieceInfo") as PdfTypeDictionary;

            if (PieceInfoDictionary.Count == 0)
            {
                return defaultMetadata;
            }

            if (PieceInfoDictionary.ContainsKey("MDPS:MetaDataDefaultSet"))
            {
                using PdfTypeDictionary DefaultSetDictionary = PieceInfoDictionary.GetBy("MDPS:MetaDataDefaultSet") as PdfTypeDictionary;

                if (DefaultSetDictionary.ContainsKey("Private"))
                {
                    using PdfTypeDictionary DefaultMetadataDictionary = DefaultSetDictionary.GetBy("Private") as PdfTypeDictionary;

                    foreach (string name in DefaultMetadataDictionary.Keys)
                    {
                        defaultMetadata.Add(name, ((PdfTypeString)DefaultMetadataDictionary.GetBy(name)).UnicodeString);
                    }
                }
            }

            return defaultMetadata;
        }
        catch (Exception ex)
        {
            return new Dictionary<string, string>();
        }
    }
}

Edited by moderator Tuesday, May 23, 2023 8:19:44 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Tuesday, May 23, 2023 8:23:26 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,094

Thanks: 7 times
Was thanked: 128 time(s) in 125 post(s)
Could you please provide a test console application that reproduces the issue at support@patagames.com
kmeier  
#3 Posted : Wednesday, May 24, 2023 1:43:23 PM(UTC)
kmeier

Rank: Newbie

Groups: Registered
Joined: 5/12/2023(UTC)
Posts: 2
United States
Location: NH

Hi Paul,
I have created this console app for you and emailed it. How do I get the PDF to you? It is larger then I can put in email at 100mb. Thanks

Edited by user Wednesday, May 24, 2023 3:55:32 PM(UTC)  | Reason: Not specified

Users browsing this topic
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.