{ "id": "85481", "key": "TIMOB-7409", "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": [ { "id": "12095", "description": "", "name": "Sprint 2012-03", "archived": true, "released": true, "releaseDate": "2012-02-12" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" }, { "id": "13070", "description": "Release 1.8 Service Pack 2", "name": "Release 1.8.2", "archived": true, "released": true, "releaseDate": "2012-02-29" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-02-14T23:29:03.000+0000", "created": "2012-01-25T15:54:10.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "module_memory", "qe-testadded" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [ { "id": "15079", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "76285", "key": "TIMOB-4367", "fields": { "summary": "Android: Table View Row Memory Leak", "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": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-12-31T23:35:22.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Expected Behavior*\r\nWhen a proxy has no more references from JavaScript or in the platform Java\r\ncode it should be collected from memory.\r\n\r\n*Actual Behavior*\r\nProxies never get reclaimed causing the applications heap to grow\r\nas proxies are created.", "attachment": [], "flagged": false, "summary": "Android: Memory leak for proxies that have no references", "creator": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "180650", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Here is a test case that helps test creating proxies and\r\ndereferencing them to simulate the collection process.\r\n\r\n{code}\r\n\r\nvar win = Ti.UI.createWindow({\r\n\ttitle: \"Proxy collection test.\",\r\n\tbackgroundColor: \"blue\",\r\n\tlayout: \"vertical\"\r\n});\r\n\r\nvar parentView = Ti.UI.createView();\r\n\r\nvar views = [];\r\n\r\nvar createViews = Ti.UI.createButton({\r\n\ttitle: 'Create Views'\r\n});\r\ncreateViews.on('click', function () {\r\n\tfor (var i = 0; i < 1000; i++) {\r\n\t\tvar view = Ti.UI.createView({backgroundColor:\"blue\"});\r\n\t\tviews.push(view);\r\n\t}\r\n});\r\nwin.add(createViews);\r\n\r\nvar addViewsAsChildren = Ti.UI.createButton({\r\n\ttitle: 'Add Views as Children'\r\n});\r\naddViewsAsChildren.on('click', function () {\r\n\tvar count = views.length;\r\n\tfor (var i = 0; i < count; i++) {\r\n\t\tparentView.add(views[i]);\r\n\t}\t\r\n});\r\nwin.add(addViewsAsChildren);\r\n\r\nvar releaseViews = Ti.UI.createButton({\r\n\ttitle: 'Release Views'\r\n});\r\nreleaseViews.on('click', function () {\r\n\tviews = [];\r\n});\r\nwin.add(releaseViews);\r\n\r\nvar releaseParentView = Ti.UI.createButton({\r\n\ttitle: \"Release Parent View\"\r\n});\r\nreleaseParentView.on('click', function () {\r\n\tparentView = Ti.UI.createView();\r\n});\r\nwin.add(releaseParentView);\r\n\r\nvar getChildren = Ti.UI.createButton({\r\n\ttitle: \"Get Children\"\r\n});\r\ngetChildren.on('click', function () {\r\n\tparentView.children.forEach(function (child) {\r\n\t\tTi.API.info(child.getHeight());\r\n\t});\r\n});\r\nwin.add(getChildren);\r\n\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-25T21:04:11.000+0000", "updated": "2012-01-25T21:04:11.000+0000" }, { "id": "180892", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Here is a test case to verify the Window proxies remain alive until\r\nthey are closed.\r\n\r\nExpected: Application should not crash when opening then closing window.\r\n\r\n{code}\r\nvar mainWindow = Ti.UI.createWindow({\r\n\ttitle: \"main window\",\r\n\tbackgroundColor: \"red\"\r\n});\r\n\r\nvar openWindowBtn = Ti.UI.createButton({\r\n\ttitle: \"Open Window\"\r\n});\r\nopenWindowBtn.on('click', function () {\r\n\tvar newWin = Ti.UI.createWindow({\r\n\t\ttitle: \"New window\",\r\n\t\tbackgroundColor: \"blue\"\r\n\t});\r\n\r\n\tvar closeBtn = Ti.UI.createButton({\r\n\t\ttitle: \"Close\"\r\n\t});\r\n\tcloseBtn.on('click', function () {\r\n\t\tnewWin.close();\r\n\t});\r\n\tnewWin.add(closeBtn);\r\n\t\r\n\tnewWin.open();\r\n});\r\nmainWindow.add(openWindowBtn);\r\n\r\nmainWindow.open();\r\n{code}", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-27T10:10:51.000+0000", "updated": "2012-01-27T10:14:52.000+0000" }, { "id": "180935", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "To check that this collection is happening correctly, you'll need to:\r\n* Make sure {{android:debuggable=\"true\"}} is in your application in tiapp.xml:\r\n(example, your app ID etc will be different)\r\n{code}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\n* Open the process w/ DDMS and make sure that Heap collection is enabled, and click \"Cause GC\"\r\n* Click \"Create Views\" several times in the app to build up the heap size\r\n* Click \"Release Views\", and using DDMS click \"Cause GC\" a few more times and you should see the memory go back down", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-27T14:30:28.000+0000", "updated": "2012-01-27T14:30:28.000+0000" }, { "id": "181333", "author": { "name": "jicks83", "key": "jicks83", "displayName": "Jick Steen", "active": true, "timeZone": "Europe/Berlin" }, "body": "Is this fix going to be merged into Mobile SDK 1.8.2 branch?", "updateAuthor": { "name": "jicks83", "key": "jicks83", "displayName": "Jick Steen", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-02-01T09:02:38.000+0000", "updated": "2012-02-01T09:02:38.000+0000" }, { "id": "181350", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Yes. ", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-01T10:01:12.000+0000", "updated": "2012-02-01T10:01:12.000+0000" }, { "id": "182258", "author": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing issue\r\n\r\nTested with Ti Studio build 1.0.8.201201262211\r\nTi Mob SDK 1.9.0.v20120207124634\r\nOSX Lion 10.7.2\r\nNexus S OS 2.3.6\r\n\r\nTested against both provided sample codes and the expected results were shown", "updateAuthor": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-07T13:37:46.000+0000", "updated": "2012-02-07T13:37:46.000+0000" }, { "id": "182933", "author": { "name": "mkrug", "key": "mkrug", "displayName": "Markus Krug", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi! Sorry for asking, I'm just wondering. You wrote this will be merged into 1.8.2 Ti Mobile. When is this happening? Before the official 1.8.2 release? Just asking cause I plan to release a new version of my app soon. By the way: I can confirm the fix in 1.9 Ti Mobile is working. Keep up the amazing work!", "updateAuthor": { "name": "mkrug", "key": "mkrug", "displayName": "Markus Krug", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-13T11:37:23.000+0000", "updated": "2012-02-13T11:37:23.000+0000" }, { "id": "182940", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This fix will be part of 1.8.2 release that is slated to go out by the end of Feb 2012.", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-13T12:11:19.000+0000", "updated": "2012-02-13T12:11:19.000+0000" }, { "id": "230360", "author": { "name": "jmlewis1", "key": "jmlewis1", "displayName": "Justin Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Maybe I'm doing something wrong, but I still see this memory leak on Android using Josh Roesslein's code sample posted 25/Jan/12 1:04 PM. I put that in my app.js, and run. I see the memory go up clicking \"Create Views\", but clicking \"Release Views\" never causes the memory use to go down.\r\n\r\nI've tried compiling against Android SDK 2.2, 3.0, and 4.0, on emulators running the same versions of Android.\r\n\r\nI've tried several versions of the Titanium SDK as well. I started with 2.1.4, then tried 2.1.5, 1.8.3, 3.0.0 and 3.1.0.\r\n\r\nI've also tried JDK versions jdk1.7.0_09, and jdk1.6.0_37.\r\n\r\nThis isn't a small leak either, it's about 1MB per click of Create Views.\r\n\r\nI've seen this in my own app, and my own testing as well. But, I tried the given example to prove to myself that it's not just my poor coding that's the issue.", "updateAuthor": { "name": "jmlewis1", "key": "jmlewis1", "displayName": "Justin Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-07T01:53:55.000+0000", "updated": "2012-12-07T01:53:55.000+0000" }, { "id": "230694", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I just tried this with 3.1.0, and the test case is working for me. Keep in mind that the 'release views' only removes the references to the view, and there may be a lag on when the VM actually garbage collects the views.", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-10T21:41:28.000+0000", "updated": "2012-12-10T21:41:28.000+0000" }, { "id": "230710", "author": { "name": "jmlewis1", "key": "jmlewis1", "displayName": "Justin Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks for the response Allen.\r\n\r\nI've found the behavior isn't quite that simple. I originally ran all of these tests in the emulator, always clicking \"Release Views\" just once. I've since switched to using a physical device.\r\n\r\nWhat I see there is, I click \"Create Views\" and memory usage goes up. I click \"Release Views\" and memory usage sometimes goes down, and sometimes doesn't. Typically, I need to hit the \"Release Views\" button many times (between 5 and 10) before the memory usage drops.\r\n\r\nI've also tried hitting \"Release Views\" then leaving the phone alone for awhile, in case it just needed time. In those cases, no matter how long I leave the phone alone, up to an hour in a couple of cases, the memory usage still doesn't go down until I hit the \"Release Views\" button several more times.\r\n\r\nAnd as a final test, I also added a \"Do Nothing\" button that has a click handler, but doesn't do anything. Clicking \"Release Views\" once, then my \"Do Nothing\" button continuously has no effect. I have to hit the \"Release Views\" button several times in most cases to see the memory usage drop.\r\n\r\nAnd, I added a print at the end of \"Release Views\" to verify that views is indeed empty, with length 0 after the first press.\r\n\r\nHowever, memory usage does always drop, if I hit \"Release Views\" enough times.\r\n\r\nI don't know if this is quirk of Android's garbage collection, or of my 3 Motorola phones, or if there's something else going on that I just don't understand.", "updateAuthor": { "name": "jmlewis1", "key": "jmlewis1", "displayName": "Justin Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-10T22:17:56.000+0000", "updated": "2012-12-10T22:17:56.000+0000" }, { "id": "232828", "author": { "name": "jmlewis1", "key": "jmlewis1", "displayName": "Justin Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "After some more experimenting, taking the Alloy sample book search application, I made a minor modification. I took everything from index, and moved it into book_search. Then I modified index so that it is a modal window with a single button with an OnClick handler that opens the book_search window.\r\n\r\nClicking the button, doing a search, the hitting back leaks memory. I've seen it lose as much as 300k at a time. It seems the amount of memory leaked is random, averaging 100k-200k/iteration. But, each search shows an increasing amount of memory usage.\r\n\r\nI do not see any of these leaks on IOS.\r\n\r\nI have tried SDK version 3.0.0GA and 3.1.0v201228131005, both show the leak.\r\n\r\nThis has only been tested on my Motorola Droid HD Maxx Android Version 4.1.1", "updateAuthor": { "name": "jmlewis1", "key": "jmlewis1", "displayName": "Justin Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-31T23:35:22.000+0000", "updated": "2012-12-31T23:35:22.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }