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

Improve memory-usage of font-cache

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.7.1
    • GUI: Font handling
    • None
    • meego

    • 2801db558c56e98753e297c1aeabd4fd2975e09a

    Description

      Assuming that a text consists of a multilength-string containing the character 0x9c and the following code is executed:

      QFontMetricsF metrics(font);
      const qreal width = metrics.width(text);

      If the used font does not provide a glyph for 0x9c, then Qt will do a fallback to other fonts that match the criteria defined in QFont to search for a glyph for 0x9c. In the case of meego this lead to the loading of 7 fonts including Arabic ones. This resulted in allocations of 1 MB inside qHBNewFace(), which are never freed until the application has been quit (see https://projects.maemo.org/bugzilla/show_bug.cgi?id=199168 for more details).

      This is of course not restricted to the character 0x9c, but each character that does not provide a glyph. We fixed this in meego by assuring that QFontMetrics does not get a multilength-string as input (which should not be done anyway), however in the scope of mobile devices I think it should be discussed whether caching all fonts this way makes sense, although no glyph could be found at all.

      Probably it is possible to unload at least the font-information that did not contain the glyph? Or maybe unprintable characters like 0x1 - 0x1 - 0x1f or 0x9c could be skipped completely before parsing fonts for a glyph?

      Attachments

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              ppenz Peter Penz
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes