{ "id": "129107", "key": "AC-1401", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-04-23T03:40:36.000+0000", "created": "2014-04-16T09:19:09.000+0000", "labels": [ "iOS", "listview" ], "versions": [], "issuelinks": [], "assignee": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:37:49.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": [], "description": "This Method create a Memory Leak\r\n\r\n{quote}\r\nmyListView.sections[ id_section ].deleteItemsAt(0,myListView.sections[ id_section ].items.length);\r\n{quote}\r\n\r\nI must remove items from a section of ListView, and add some items later with the method (setItems), and I noticed that by Instruments, when call (deleteItemsAt), the objects contained in the item are not unloaded from memory, and then, when recall SetItems , I have a memory leaks problem\r\n\r\n\r\nTEST CODE\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow();\r\n\r\nvar template = {\r\n\tchildTemplates : [{\r\n\t\ttype : 'Ti.UI.Label',\r\n\t\tbindId : 'nome_oggetto',\r\n\t\tproperties : {\r\n\t\t\tcolor : 'black',\r\n\t\t\tleft : 10\r\n\t\t},\r\n\t}, {\r\n\t\ttype : 'Ti.UI.Button',\r\n\t\tbindId : 'button_piu',\r\n\t\tproperties : {\r\n\t\t\twidth : 30,\r\n\t\t\theight : 30,\r\n\t\t\tright : 10,\r\n\t\t\ttitle : '+',\r\n\t\t\tvisible : false,\r\n\t\t\tfont : {\r\n\t\t\t\tfontSize : 30\r\n\t\t\t},\r\n\t\t\tcolor : \"black\",\r\n\t\t\ttop : 6,\r\n\t\t\tobj : \"\"\r\n\t\t},\r\n\t\tevents : {\r\n\t\t\tclick : test\r\n\t\t}\r\n\t}],\r\n};\r\n\r\nvar array_app = [];\r\n\r\nfor (var i = 0; i < 10; i++) {\r\n\tarray_app.push({\r\n\t\tnome_oggetto : {\r\n\t\t\ttext : \"row \" + i,\r\n\t\t\tcolor : \"black\"\r\n\t\t},\r\n\t\tbutton_piu : {\r\n\t\t\tvisible : true\r\n\t\t},\r\n\t\tproperties : {\r\n\t\t\tbackgroundColor : \"white\",\r\n\t\t\theight : 50,\r\n\t\t\tselectionStyle : Ti.UI.iPhone.ListViewCellSelectionStyle.NONE,\r\n\t\t\tfont : {\r\n\t\t\t\tfontSize : 18\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n}\r\n\r\nvar listView = Titanium.UI.createListView({\r\n\ttemplates : {\r\n\t\t'mytemplate' : template\r\n\t},\r\n\tdefaultItemTemplate : 'mytemplate'\r\n});\r\n\r\nvar section = Ti.UI.createListSection({\r\n title : \"section 1\"\r\n});\r\n\r\nsection.setItems(array_app);\r\n\r\nvar array_section = [];\r\narray_section.push(section);\r\n\r\nlistView.sections = array_section;\r\n\r\nvar delete_btn = Ti.UI.createButton({\r\n\ttitle : \"remove item\",\r\n\twidth : 100,\r\n\tbottom : 30\r\n});\r\n\r\ndelete_btn.addEventListener('click', function(e) {\r\n\tlistView.sections[0].deleteItemsAt(0, 1);\r\n});\r\n\r\nfunction test(){\r\n\t\r\n}\r\n\r\nwin.add(listView);\r\nwin.add(delete_btn);\r\n\r\nwin.open();\r\n{code}", "attachment": [ { "id": "47340", "filename": "Schermata 2014-04-16 alle 21.44.49.png", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2014-04-16T19:48:52.000+0000", "size": 106663, "mimeType": "image/png" }, { "id": "47341", "filename": "Schermata 2014-04-16 alle 21.45.00.png", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2014-04-16T19:48:52.000+0000", "size": 103096, "mimeType": "image/png" } ], "flagged": false, "summary": "iOS: Memory leak on iOS when remove items from section of ListView", "creator": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "subtasks": [], "reporter": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "environment": "Titanium Studio, build: 3.2.1.201402041146 , Apple 7.0 SDK , xCode 5.0 , Titanium SDK 3.2.2 GA", "comment": { "comments": [ { "id": "301123", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Please provide a simple runnable test case so that we can reproduce this issue in-house.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-16T17:48:46.000+0000", "updated": "2014-04-16T17:48:46.000+0000" }, { "id": "301149", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "body": "description updated with a test code and screenshot", "updateAuthor": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2014-04-16T19:43:04.000+0000", "updated": "2014-04-16T19:54:06.000+0000" }, { "id": "301209", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Removing an item from a ListView section marks it ready for garbage collection but it does not mean that the object is collected immediately. Garbage collection timing is based on a number of different factors. A better test would be to add and remove items in a large loop and see if the memory usage continues to go up or stabilizes at some point.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-17T05:31:46.000+0000", "updated": "2014-04-17T05:31:46.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }