Sign In  Sign Up Live-Chat

Unordered List Memory Leak

Last post 10-10-2007, 4:26 AM by Hans.firefox. 7 replies.
Sort Posts: Previous Next
  •  09-25-2007, 8:33 AM 96064

    Unordered List Memory Leak

    Attachment: Present (inaccessible)
    Aspose.Pdf appears to be leaking an explosive ammount of memory in one of our production application while using version 3.5.7.0. This appears to happen when we ask Aspose.Pdf to render a Text element that contains an unordered list. I've included my test snippet below and have attached the project to this post.

    class Program
       {
            static void Main(string[] args)
            {
                for (int i = 0; i < 100000; i++)
                {
                    CreatePdf();
                }
            }

            private static void CreatePdf()
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    Pdf pdf = new Pdf();
                    Section sec = pdf.Sections.Add();
                    Text txt = new Text("<ul><li>Bullet 1</li><li>Bullet 2</li><li>Bullet 3</li></ul>");
                    txt.IsHtmlTagSupported = true;
                    sec.Paragraphs.Add(txt);
                    pdf.Save(stream);
                    stream.Close();
                }
            }
        }

    In this case, memory usage rapidly runs towards OOME. If I disable IsHtmlTagSupported, I see acceptable behavior. Additionally, if I change the content to a paragraph ("<p>A paragraph</p>"), everything seems resonable. It appears to be related to the unordered list rendered as HTML.

    Are you able to reproduce this? And if so, are there any workarounds or fixes that can be applied in the near future?


     
  •  09-25-2007, 10:47 PM 96179 in reply to 96064

    Re: Unordered List Memory Leak

    Hi,

    Thank you for considering Aspose.

    I have tested your code and I get resonable memory usage for all three cases. The memory usage is lesser for when IsHtmlTagSupported is disabled, which is understandable that, with out html tags lesser processing will be required.

    Thanks.

     
  •  09-26-2007, 4:24 PM 96322 in reply to 96179

    Re: Unordered List Memory Leak

    We're currently evaluating Aspose.PDF for use in a high-volume web applictation, so this immediately caught my attention. I was able to reproduce this behavior.

    I found that memory usage held steady when IsHtmlTagSupported was false. It was also consistent when IsHtmlTagSupported was true but list markup wasn't included.

    However, when IsHtmlTagSupported was true and a list (ordered or unordered) was provided to the Text instance, I found the memory usage to increase by approximately 4MB per iteration.

    While I would expect HTML conversion and rendering to be costlier from a memory standpoint, I'd expect it to be reclaimed by garbage collector. It wasn't; after 100 iterations, it ran right up to ~400MB. I wouldn't consider that reasonable memory usage. In fact, it smells like a memory leak.

    Chris
     
  •  09-26-2007, 5:52 PM 96331 in reply to 96322

    Re: Unordered List Memory Leak

    Attachment: Present (inaccessible)

    Adeel & Chris,

    Thanks for the replies. I appreciate you taking the time to test this. I've looked into this a bit more and I can confirm that my experience matches that of Chris.

    I've attached 3 listing that show my total memory usage as reported via GC.GetTotalMemory(false) for each of the test scenerios I've described.

    listing-nohtml.txt:
    Constructs txt with "<p>This is a paragraph.</p>" and set IsHtmlSupported = false

    Listing-p.txt:
    Constructs txt with "<p>This is a paragraph.</p>" and set IsHtmlSupported = true

    listing-ul.txt:
    Constructs txt with "<ul><li>Bullet 1</li><li>Bullet 2</li><li>Bullet 3</li></ul>" and set IsHtmlSupported = true.

    The “nohtml” and the “p” test show almost identical memory usage. The “ul” test shows runaway memory usage hitting 1 GB of usage around iteration 250.

    Just to be clear, I'm not considering Aspose. My organization has purchased a license and is experiencing this problem in our production web application. Any support that you can provide would be greatly appreciated.

    Thanks,
    Kyle

     
  •  09-26-2007, 10:10 PM 96349 in reply to 96331

    Re: Unordered List Memory Leak

    Dear Kyle,

    I have reproduced this error with allocation profiler and logged this issue as PDFNET-3793. We will try to fix it soon.

    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  10-03-2007, 4:13 PM 97230 in reply to 96349

    Re: Unordered List Memory Leak

    Tommy,

    Could you provide an estimated date for the completion of this fix?

    Thanks,
    Kyle
     
  •  10-03-2007, 8:53 PM 97244 in reply to 97230

    Re: Unordered List Memory Leak

    Hi,

      Thanks very much for considering Aspose.Pdf. We are trying to fix it by Oct.9th. Thank you again for your patience and information.


    Cynthia Hu
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  10-10-2007, 4:26 AM 98060 in reply to 97230

    Re: Unordered List Memory Leak

    Attachment: Present (inaccessible)
    Hi,

    The problem has been resolved. Please try the attachment before offical hotfix.

    Best regards.

    Hans Zhang
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML