import QtQuick 2.5 Rectangle { id: root width: 1024 height: 768 color: "white" readonly property int count: 10 property int current: 0 Loader { id: content active: false asynchronous: false anchors.centerIn: parent sourceComponent: Item { Component.onDestruction: { console.warn("parent deleted"); } Component.onCompleted: { console.warn("parent created"); } } } property Component c: null Timer { id: tmr running: false repeat: false interval: 0 onTriggered: { c = Qt.createComponent("generated/Bla%1.qml".arg(root.current), Component.Asynchronous, content.item); // c = Qt.createComponent("generated/Bla%1.qml".arg(root.current), Component.PreferSynchronous, content.item); // c = Qt.createComponent("generated/Bla1.qml", content.item); // still leaks if (c.status == Component.Ready) { finishCreation(); } else { c.statusChanged.connect(finishCreation); } if (root.current % 1000 === 0) { console.log("current: " + root.current + " parent: " + content.item + " status: " + c.status); } root.current++; } } function finishCreation() { if (c.status == Component.Ready) { tmr.start(); } else if (c.status == Component.Error) { console.warn("should not happen"); } } MouseArea { anchors.fill: parent onClicked: { if (content.active) { tmr.stop(); content.active = false; console.log("stopped loading at " + root.current); } else { content.active = true; tmr.start(); console.log("started loading"); } } } Row { anchors { left: parent.left bottom: parent.bottom } width: 150 height: 50 Rectangle { color: "green" width: 50 height: 50 MouseArea { anchors.fill: parent onClicked: { console.log("release()"); free.release(root); gc(); } } } Rectangle { color: "yellow" width: 50 height: 50 MouseArea { anchors.fill: parent onClicked: { console.log("trim()"); free.trim(root); gc(); } } } Rectangle { color: "red" width: 50 height: 50 MouseArea { anchors.fill: parent onClicked: { // console.log("clear()"); free.clear(root); // gc(); } } } } }