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

QML TextEdit leaks memory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P1: Critical P1: Critical
    • None
    • 5.12.2
    • None
    • Windows 10
    • iOS/tvOS/watchOS, Windows

      TextEdit seems to leak memory when text is entered and deleted. This was reproduced on Windows 10 and iOS (iPhone 11 pro, 14.6) with Qt 5.12.2 so far. Perhaps more platforms are affected.

      This becomes very apparent when inputting lots of text, some hundreds of lines or more, and watching the application's memory consumption. A default-created (empty QML) project with the following code quickly gets from ~80mb to >1500mb memory consumption.

      After deleting the text from the TextEdit, the memory consumption goes down but stays at ~800mb (10x the initial amount!). In more complex applications with lots of QML, custom fonts, etc., where the TextEdit is supposed to hold large texts, the problem is amplified by a factor of 2-10, and breaks the user experience (the application slows down until crashing in the worst case).

      My minimal example:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
          width: 1024
          height: 768
          visible: true
          title: qsTr("Hello World")
      
          TextEdit {
              anchors.fill: parent
          }
      }
      

      // EDIT: Probably related to https://bugreports.qt.io/browse/QTBUG-103819.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            julianw Julian Weiß
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes