Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-114823

QtPDF Qt5.15.12 Memory Leak

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.15.12
    • PDF
    • None
    • Linux, Qt5.15.12, QtPDF compiled by ourselves based on gcc 4.6
    • Linux/X11

    Description

      We discovered a memory leak issue related to the use of QtPDF within Qt5.15.12.
      Starting from the example provided in the sources of QtPDF entitled "multipage", if you zoom-in and zoom-out several times in a row, you can see, with the Linux "top" command for example, that the RSS of the process increases infinitely.
      If you upload a PDF file a little larger than the one provided in the example, you can highlight the problem even more easily.
      I reported the problem to online support, the answer was not convincing to me, or maybe I need help to understand it:

      ///////////////////////////////////////////////////////////////
      Hi William,

      Thank you for contacting Qt Support.

      I tried this on Qt 5.15.14 on Ubuntu 20.04, using a 200MB PDF that contains 120 pages filled with photos. I did as you said (scrolled around, zoomed in, zoomed out repeatedly). I monitoring the memory usage using this command and looked at the "RSS" column:

      pmap -x $(pidof multipage)

      At the start of my test,

      • 78 MB was mapped to "Anonymous" memory
      • 30 MB were mapped to the Qt libraries
      • 93 MB were mapped to other system libraries and assets

      At the end of my test,

      • 118 MB was mapped to "Anonymous" memory
      • 30 MB were mapped to the Qt libraries
      • 107 MB were mapped to other system libraries and assets

      This shows that there is no leak in the Qt libraries. The large increase in "Anoymous" memory suggests that the issue you're seeing is caused by memory fragmentation in glibc. Please see Ulf's comments at https://bugreports.qt.io/browse/QTBUG-105915 – the way to resolve this is to use a custom memory allocator.

      I hope this clarifies things.
      ///////////////////////////////////////////////////////////////

      So the answer is no, it does not clarify, and for me there is a real issue.
      I don't understand the memory fragmentation issue. If I close the PDF document, at least I expect to find a RSS value equal to the RSS value I had before loading a PDF document and displaying it.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              srutledg Shawn Rutledge
              william_soragna William SORAGNA
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes