{"action":"created","issue":{"url":"https://api.github.com/repos/qmlweb/qmlweb/issues/150","repository_url":"https://api.github.com/repos/qmlweb/qmlweb","labels_url":"https://api.github.com/repos/qmlweb/qmlweb/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/qmlweb/qmlweb/issues/150/comments","events_url":"https://api.github.com/repos/qmlweb/qmlweb/issues/150/events","html_url":"https://github.com/qmlweb/qmlweb/issues/150","id":142915780,"number":150,"title":"Improve QmlWeb's memory management","user":{"login":"akreuzkamp","id":6573625,"avatar_url":"https://avatars.githubusercontent.com/u/6573625?v=3","gravatar_id":"","url":"https://api.github.com/users/akreuzkamp","html_url":"https://github.com/akreuzkamp","followers_url":"https://api.github.com/users/akreuzkamp/followers","following_url":"https://api.github.com/users/akreuzkamp/following{/other_user}","gists_url":"https://api.github.com/users/akreuzkamp/gists{/gist_id}","starred_url":"https://api.github.com/users/akreuzkamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akreuzkamp/subscriptions","organizations_url":"https://api.github.com/users/akreuzkamp/orgs","repos_url":"https://api.github.com/users/akreuzkamp/repos","events_url":"https://api.github.com/users/akreuzkamp/events{/privacy}","received_events_url":"https://api.github.com/users/akreuzkamp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/qmlweb/qmlweb/labels/discuss","name":"discuss","color":"fef2c0"},{"url":"https://api.github.com/repos/qmlweb/qmlweb/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/qmlweb/qmlweb/milestones/4","html_url":"https://github.com/qmlweb/qmlweb/milestones/0.4.0","labels_url":"https://api.github.com/repos/qmlweb/qmlweb/milestones/4/labels","id":1591571,"number":4,"title":"0.4.0","description":null,"creator":{"login":"ChALkeR","id":291301,"avatar_url":"https://avatars.githubusercontent.com/u/291301?v=3","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2016-02-18T20:18:34Z","updated_at":"2016-04-19T05:49:29Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2016-03-23T10:03:40Z","updated_at":"2016-06-28T12:31:29Z","closed_at":null,"body":"in QML you can delete Items. Think e.g. of a Repeater, whose model-number decreases. We need to make sure, that all bindings and references are deleted and the object is garbage-collected.\r\n\r\nComing from the C++ world, I have no clue how to do proper memory management in garbage-collected languages. So far, the ideas I have are:\r\n1) Create a big array of all objects we have. There we'd have a reference to each object, everywhere else we'd not hold references, but only the index of the object in our big array. Dereferencing would be bigArray[someBindingId]. Now we can delete objects by simply resetting the array entry to null. As soon as we encounter a reference to a deleted object, we'll recognize and clean up. Performance impact would probably be low (array-access is very fast), but we'd have dead references lying around and would need a lot of boilerplate code to check if a reference is still valid.\r\n2) Keep lists like \"$tidyupList\" containing references to child objects, bindings and stuff we need to tidy up when deleting objects. This is how it works currently. It needs no boilerplate code, but is very weak-kneed, as it's easy to miss a reference.\r\n\r\nI'm not really happy with either way...\r\nI hope you've got some good input! :)"},"comment":{"url":"https://api.github.com/repos/qmlweb/qmlweb/issues/comments/229034972","html_url":"https://github.com/qmlweb/qmlweb/issues/150#issuecomment-229034972","issue_url":"https://api.github.com/repos/qmlweb/qmlweb/issues/150","id":229034972,"user":{"login":"akreuzkamp","id":6573625,"avatar_url":"https://avatars.githubusercontent.com/u/6573625?v=3","gravatar_id":"","url":"https://api.github.com/users/akreuzkamp","html_url":"https://github.com/akreuzkamp","followers_url":"https://api.github.com/users/akreuzkamp/followers","following_url":"https://api.github.com/users/akreuzkamp/following{/other_user}","gists_url":"https://api.github.com/users/akreuzkamp/gists{/gist_id}","starred_url":"https://api.github.com/users/akreuzkamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akreuzkamp/subscriptions","organizations_url":"https://api.github.com/users/akreuzkamp/orgs","repos_url":"https://api.github.com/users/akreuzkamp/repos","events_url":"https://api.github.com/users/akreuzkamp/events{/privacy}","received_events_url":"https://api.github.com/users/akreuzkamp/received_events","type":"User","site_admin":false},"created_at":"2016-06-28T12:31:29Z","updated_at":"2016-06-28T12:31:29Z","body":"@ChALkeR With \"dangling reference\" I mean a reference to an object, that is supposed to be deleted. e.g.\r\n```qml\r\nFocusScope {\r\n    id: fs\r\n    property Item fi\r\n    Repeater {\r\n        id: rep\r\n        model: 5\r\n\r\n        Rectangle {\r\n            width: 50; height: 50; color: \"orange\"\r\n            onActiveFocusChanged: if (rep.model == 0) console.log(\"I'm wrong behavior\");\r\n        }\r\n    }\r\n\r\n    Component.onCompleted: {\r\n        fi = rep.itemAt(3);\r\n        fi.forceActiveFocus();\r\n    }\r\n}\r\n```\r\n`fs` now holds a reference to the 4th item of the repeater. What will happen to it, when `rep.model` is set to 0? Now it's a \"dangling reference\". Obviously it's not dangling in the C++ way, as the object is not destructed yet. But still it's logically deleted.\r\n\r\nWith \"undefined behavior\" I mean whatever happens if you call a function on an object, that is supposed not to exist anymore. E.g. if `fs` got/lost focus and thus sets `activeFocus` on `fi`. That could trigger wrong console outputs, exceptions, wrong data to be sent to the server or Great Britain to leave the EU.\r\n\r\n"}}
{"actor":{"display_login":"akreuzkamp"}}