{ "id": "90738", "key": "TIMOB-8857", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-04-27T16:28:13.000+0000", "created": "2012-04-23T08:08:06.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "SupportTeam", "core" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [ { "id": "16813", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "90739", "key": "TIMOB-8858", "fields": { "summary": "Android: Destroying a parent object (setting it to null) it won't destroy any child objects", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-04-30T09:34:35.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h6.Issue\r\n\"Destroying a parent object (setting it to null) will destroy any child objects as long as no other references to those child objects exist. Consider the following code snippet to get a feel for the specifics:\"\r\n\r\nh6.Tested on\r\niOS 5 simulator\r\n\r\nh6.Test Case 1\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow({\r\n\ttitle: 'Main',\r\n\texitOnClose: true,\r\n\tfullscreen: false,\r\n\tnavBarHidden: false,\r\n\tbackgroundColor: 'gray'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n // parameters go here...\r\n title: 'deletes the view and its proxy,\\nbut not the button!',\r\n backgroundColor: 'red'\r\n});\r\nvar view = Ti.UI.createView({\r\n // some parameters here...\r\n borderRadius:10,\r\n top: 15\r\n});\r\nview.add(button);\r\nwin.add(view); \r\nwin.addEventListener('click', function(){\r\n\t// ... later\r\n\twin.remove(view); // view & button still exist\r\n\tview = null; //deletes the view and its proxy, but not the button!\r\n});\r\n\r\nwin.open();\r\n{code}\r\n\r\n\r\nh6.So Having button set to null do get released (as seen in Instruments).\r\n\r\n\r\nh6.Test Case 2\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow({\r\n\ttitle: 'Main',\r\n\texitOnClose: true,\r\n\tfullscreen: false,\r\n\tnavBarHidden: false,\r\n\tbackgroundColor: 'gray'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n // parameters go here...\r\n title: 'deletes the view and its proxy,\\nbut not the button!',\r\n backgroundColor: 'red'\r\n});\r\nvar view = Ti.UI.createView({\r\n // some parameters here...\r\n borderRadius:10,\r\n top: 15\r\n});\r\nview.add(button);\r\nwin.add(view); \r\nwin.addEventListener('click', function(){\r\n\t// ... later\r\n\twin.remove(view); // view & button still exist\r\n\tview = null; // deletes the view and its proxy, but not the button!\r\n\tbutton = null;//do get released\r\n});\r\n\r\nwin.open();\r\n{code}\r\n\r\nh6.Additional info\r\nTest results and its corresponding screenshots:\r\n\r\nTestCase 1 - Button not being set > InstrumentsProxies_2.1.0_TestCase1_a.jpg\r\nTestCase 1 - Button set to null > InstrumentsProxies_2.1.0_TestCase1_b.jpg\r\n\r\nTestCase 2 - Button not being set > InstrumentsProxies_2.1.0_TestCase2_a.jpg\r\nTestCase 2 - Button set to null > InstrumentsProxies_2.1.0_TestCase2_b.jpg\r\n\r\nh6.Wiki Link\r\nhttps://wiki.appcelerator.org/display/guides/Managing+Memory+and+Finding+Leaks#ManagingMemoryandFindingLeaks-WhenTitaniumreleasesmemory\r\n", "attachment": [ { "id": "27336", "filename": "InstrumentsProxies_2.1.0_TestCase1_a.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-04-23T08:13:32.000+0000", "size": 107170, "mimeType": "image/jpeg" }, { "id": "27337", "filename": "InstrumentsProxies_2.1.0_TestCase1_b.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-04-23T08:13:32.000+0000", "size": 97060, "mimeType": "image/jpeg" }, { "id": "27338", "filename": "InstrumentsProxies_2.1.0_TestCase2_a.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-04-23T08:13:32.000+0000", "size": 109796, "mimeType": "image/jpeg" }, { "id": "27339", "filename": "InstrumentsProxies_2.1.0_TestCase2_b.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-04-23T08:13:32.000+0000", "size": 107590, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "iOS: Destroying a parent object (setting it to null) it won't destroy any child objects", "creator": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "iOS: 5\r\nTitanium SDK: 2.1.0", "comment": { "comments": [ { "id": "193004", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test case 1. is invalid. The button should still exist because there is still a reference to it; {{var button}}.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-04-27T13:59:35.000+0000", "updated": "2012-04-27T13:59:35.000+0000" }, { "id": "193005", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test case is invalid. The button is managed correctly because it still has a reference.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-04-27T14:00:14.000+0000", "updated": "2012-04-27T14:00:14.000+0000" }, { "id": "193009", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "@Stephen Does that mean nulling that proxy should be done explicitly? i.e. button = null; ", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-04-27T14:06:57.000+0000", "updated": "2012-04-27T14:06:57.000+0000" }, { "id": "193039", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Yes. Please do not reopen tickets to ask a question.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-04-27T16:28:13.000+0000", "updated": "2012-04-27T16:28:13.000+0000" }, { "id": "193141", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing issue; requires no further validation. Please see Opie's description on the companion Android ticket for any more specific details.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-04-30T09:34:35.000+0000", "updated": "2012-04-30T09:34:35.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }