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

Memory Leak when using a custom QAbstractItemModel

    XMLWordPrintable

Details

    • All

    Description

      I encountered a bug when a customer had a UI running for a long time, the application ran out of memory.

      I condensed the whole setup in a trival example to reproduce the issue.
      It consists of a subclassed QAbstractItemModel that holds actually no data but just the count of items. Also, there can only be a maximum number of items (25 by default) in the list. The Model should behave like deque, when a new item is appended and the max number of items was reached, the first item is removed. I use begin/endInsertRows and begin/endRemoveRows only. The model is attached to Repeater with an empty Item as delegate.

      When clicking the button in the example, each time, 100 items are added to the list.
      The button caption shows the item count in the list, which is capped at 25.

      However, when you click the button several times you can observe an increase of used memory in the task manager.

      I also did a heaptrace with Visual Studio it seems to me that there dangling QQuickItems in memory and the issue gets worse the more complex the delegates are.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            michaelwinkelmann Michael Winkelmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes