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

Regression: large increase in RAM usage for object literals that use numbers as keys

    XMLWordPrintable

Details

    • 037ac0f08e9365ecf58af52749f262de50d97752 (qtdeclarative)

    Description

      The following example can be used to demonstrate the issue:

      import QtQuick 2.0
      
      Item {
          width: 400; height: 400
      
          Component {
              id: myObj
              QtObject {
                  property variant myProp: { "3000": "yes", "8000": "no"}
                  property variant myProp2: { "3000": "yes", "8000": "no"}
                  property variant myProp3: { "3000": "yes", "8000": "no"}
                  property variant myProp4: { "3000": "yes", "8000": "no"}
                  property variant myProp5: { "3000": "yes", "8000": "no"}
                  property variant myProp6: { "3000": "yes", "8000": "no"}
                  property variant myProp7: { "3000": "yes", "8000": "no"}
                  property variant myProp8: { "3000": "yes", "8000": "no"}
                  property variant myProp9: { "3000": "yes", "8000": "no"}
                  property variant myProp10: { "3000": "yes", "8000": "no"}
      
                  property variant myTmpProp
                  property variant key: "3000"
      
                  Component.onCompleted: {
                      for (var i = 0; i < 50; ++i) {
                          myTmpProp = myProp [key]
                      }
                  }
              }
          }
      
          Timer {
              interval: 16
              repeat: true
              running: true
              onTriggered: {
                  myObj.createObject()
              }
          }
      
          Timer {
              interval: 1000
              repeat: true
              running: true
              onTriggered: {
                  gc()
              }
          }
      }
      

      After running for 20 iterations of top, RES is reported as:
      Qt 5.1.1: 62MB
      Qt 5.2.x: 137MB

      Changing from variant to var improves things somewhat:
      Qt 5.1.1: 61MB
      Qt 5.2.x: 81MB

      Changing from numbers for keys to words for keys results in significantly better results:
      Qt 5.1.1: ~59MB
      Qt 5.2.x: ~54MB

      Attachments

        For Gerrit Dashboard: QTBUG-36803
        # Subject Branch Project Status CR V

        Activity

          People

            shausman Simon Hausmann
            mbrasser Michael Brasser
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes