Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.1
-
None
-
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 |
78124,1 | WIP: Force the use of sparse arrays for object literals with numeric keys. | stable | qt/qtdeclarative | Status: ABANDONED | -2 | 0 |
78251,1 | Reduce memory usage for object literals with integral keys | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |