{ "id": "124358", "key": "ALOY-915", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2014-01-03T17:17:55.000+0000", "created": "2014-01-03T16:45:59.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "supportTeam" ], "versions": [ { "id": "15403", "description": "Alloy 1.3.0", "name": "Alloy 1.3.0", "archived": false, "released": true, "releaseDate": "2013-12-20" } ], "issuelinks": [], "assignee": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-06-22T13:23:20.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": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "h6.Issue description\r\nAlloy Collection is not releasing memory properly if fetch is run WITH a callback.\r\n\r\nh6.Steps to reproduce\r\nTi project files here: https://www.dropbox.com/sh/f4h0fkyp08numrm/W9rvtLZ1Rr\r\n\r\n- To run the app WITH a memory leak:\r\n\r\n1) In the ledgerlists.fetch({.... ; lines 15-18 of test1.js ; UNCOMMENT these lines and build the app. To be clear, the lines to un-comment are:\r\n\r\n{quote}\r\nsuccess: function(collection, response){\r\n console.log(\"fetch finished\");\r\n console.log(response); \r\n} \r\n{quote}\r\n\r\n2) Run Instruments\r\n\r\n{quote}\r\nselect \"Allocations\" icon, click \"Choose\"\r\npick the drop down box \"Choose Target\"\r\nselect \"Attach to Process\" ->\r\nscroll down to the \"System\" heading area, then underneath that, find the app (leakTest1)\r\nclick on Record (top left); enter uid/pwd if needed on mac osx\r\nin the top right corner of Instruments window, put \"TiUI\" to the filter box \r\nnow go back to the Ti app that is open/running\r\nopen up the modal window by clicking on the \"TEST1\" button\r\nclose the modal window (then take a look at Instruments)\r\nopen up the modal window again, then look at Instruments\r\nrepeat 11 & 12 a number of times (5 or 6)\r\nyou should see the number of retained objects for the listview increasing. they never get released.\r\n{quote}\r\n\r\n- To run the app WITHOUT a memory leak:\r\n\r\n1) In the ledgerlists.fetch({.... ; lines 15-18 of test1.js ; COMMENT OUT these lines and build the app. To be clear, the lines to COMMENT OUT are:\r\n\r\n{quote}\r\nsuccess: function(collection, response){\r\n console.log(\"fetch finished\");\r\n console.log(response); \r\n} \r\n{quote}\r\n\r\n**RE-SAVE & CLEAN BUILD OF Ti PROJECT\r\n\r\nRepeat the above steps 2.->13. to watch Instruments\r\n\r\nYou should not see any memory leak. All the objects are eventually released.\r\n\r\nh6.Thoughts\r\nWe tried out to unbind the Collection using reset method after the Controller Window closed:\r\n\r\nE.I. http://stackoverflow.com/questions/9202599/how-do-i-unbind-a-backbone-collection-fetch-callback\r\n\r\nSince \"Using reset with no arguments is useful as a way to empty the collection.\" http://docs.appcelerator.com/backbone/0.9.2/#Collection-reset\r\n\r\nWe are seeing the Ti objects getting released after the 3rd or 4th time (Under #transient column) Screen shoot: AlloyMemoryLeak_Instruments.jpg\r\n\r\nQuoted the code lines that were added on our side for testing purposes (controllers/test1.js):\r\n{quote}\r\n$.closeButton.addEventListener('click', function(e) {\r\n $.win1.close();\r\n $.win1.removeAllChildren();\r\n $.destroy();\r\n ledgerlists.reset();\r\n}); \r\n{quote}\r\n\r\nWe also attempted to use the Alloy.Collections.instance method with the name of the model file minus the extension as the only parameter to create or access the singleton. However this ended up just getting released the TiWindow \r\n\r\nScreen shoot: AlloyCollection_SingletonInstance.jpg\r\n\r\nFor example (controllers/test1.js):\r\n{quote}\r\n// some restful endpoint - testing purposes only\r\n//var ledgerlists = Alloy.createCollection('ledgerlist');\r\nvar ledgerlists = Alloy.Collections.instance('ledgerlist');\r\n{quote}", "attachment": [ { "id": "44915", "filename": "AlloyCollection_FetchMethod.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T16:58:55.000+0000", "size": 321048, "mimeType": "image/jpeg" }, { "id": "44914", "filename": "AlloyCollection_SingletonInstance.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T16:45:59.000+0000", "size": 332387, "mimeType": "image/jpeg" }, { "id": "44913", "filename": "AlloyMemoryLeak_Instruments.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T16:45:59.000+0000", "size": 312267, "mimeType": "image/jpeg" }, { "id": "44916", "filename": "leakTest1.zip", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T17:00:53.000+0000", "size": 9461788, "mimeType": "application/zip" } ], "flagged": false, "summary": "Alloy Collection (RESTful) is not releasing memory properly", "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": "TiSDK 3.2.0.GA", "comment": { "comments": [ { "id": "286587", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Project link is a 404. Also, you mention REST, is this using a 3rd party REST adapter? If so, you'll likely get more help reporting the issue to the author of the adapter since we don't support those as part of the Alloy project.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T16:54:57.000+0000", "updated": "2014-01-03T16:54:57.000+0000" }, { "id": "286588", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Forgot to attach a screen shoot (AlloyCollection_FetchMethod.jpg) where there is no memory leak (no callback defined)", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T16:58:55.000+0000", "updated": "2014-01-03T16:58:55.000+0000" }, { "id": "286593", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This issue, based on what I've been given here, appears specific to the restapi.js adapter, which is a 3rd party sync adapter created by Mads Moller here: https://github.com/viezel/napp.alloy.adapter.restapi . It is outside the scope of the ALOY project.\r\n\r\nYou should contact Mads by either logging an issue on the project or messaging him directly to test this and get it resolved. He is generally pretty responsive, but you can contact me if you have a hard time getting help. ", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-03T17:17:55.000+0000", "updated": "2014-01-03T17:17:55.000+0000" }, { "id": "287365", "author": { "name": "angus_johnston@me.com", "key": "angus_johnston@me.com", "displayName": "Angus Johnston", "active": true, "timeZone": "Australia/Sydney" }, "body": "thanks Tony / Eduardo, ive left a message just now on the github repo for Mads. ", "updateAuthor": { "name": "angus_johnston@me.com", "key": "angus_johnston@me.com", "displayName": "Angus Johnston", "active": true, "timeZone": "Australia/Sydney" }, "created": "2014-01-09T03:59:00.000+0000", "updated": "2014-01-09T03:59:00.000+0000" }, { "id": "299268", "author": { "name": "javenwang", "key": "javenwang", "displayName": "Javen Wang", "active": true, "timeZone": "Asia/Shanghai" }, "body": "Hi guys, I've created a PR for this issue: https://github.com/viezel/napp.alloy.adapter.restapi/pull/33", "updateAuthor": { "name": "javenwang", "key": "javenwang", "displayName": "Javen Wang", "active": true, "timeZone": "Asia/Shanghai" }, "created": "2014-03-30T07:19:37.000+0000", "updated": "2014-03-30T07:19:37.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }