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

Memory leak in QFontDatabase (fontconfig)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.9.3
    • GUI: Font handling
    • None
    • Linux/X11

      When we lately started using Clangs address sanitizer for debugging purposes, our programs now report memory leaks when the exited (see the attached log for details).

      There mem leaks are caused as the QFontDatabase destructor is never called on program exit. I copied the code from the destructor to our main function right before exit and the mem leak was gone.

      It looks like there is a problem in this piece of code:

       

      QPlatforstd::unique_ptrmFontDatabase *QPlatformIntegration::fontDatabase() const 
      { 
         static QPlatformFontDatabase *db = nullptr; 
         if (!db) { 
             db = new QPlatformFontDatabase; 
         } 
         return db; 
      }

      There db will never be deleted - which might be fine for other platforms but for Linux/X11 with fontconfig this causes the mem leaks. 

       

      Maybe a std::unique_ptr or a qAddPostRoutine() could help.

        1. error.txt
          11 kB
          Marc Langenbach
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            mlangen Marc Langenbach
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes