{ "id": "110687", "key": "TIMOB-13250", "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": "15419", "description": "2013 Sprint 09 Core", "name": "2013 Sprint 09 Core", "archived": true, "released": true, "releaseDate": "2013-05-06" }, { "id": "15107", "description": "2013 Sprint 09", "name": "2013 Sprint 09", "archived": true, "released": true, "releaseDate": "2013-05-06" } ], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2013-05-03T22:44:19.000+0000", "created": "2013-03-06T14:48:33.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "exalture", "triage" ], "versions": [], "issuelinks": [], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-21T22:15:26.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": "When closing a webview, memory is not released properly. Removing the webview and nulling variables does not solve the problem.\r\n\r\nApp.js:\r\n\r\n{code:javascript}\r\n(function() {\t\r\n\tvar w = Ti.UI.createWindow();\r\n\tw.exitOnClose = true;\r\n\tw.setBackgroundColor(\"red\");\r\n\tw.setNavBarHidden(true);\r\n\t\r\n\tvar b = Ti.UI.createButton();\r\n\tb.setTitle(\"Press me\");\r\n\tb.addEventListener('click', function()\r\n\t{\r\n\t var w2 = Ti.UI.createWindow();\r\n\t w2.setModal(true);\r\n\t w2.setNavBarHidden(true);\r\n\t w2.setBackgroundColor(\"white\");\r\n\t \r\n\t var l = Titanium.UI.createWebView({\r\n\t\t html:'hello world'\r\n\t });\r\n\t w2.add(l);\r\n\t w2.addEventListener('android:back', function(e){\r\n\t \t w2.remove(l); \r\n\t \t l = null;\r\n\t \t w2.close();\t \r\n\t \t w2 = null; \t \r\n\t\t});\r\n\t w2.open();\r\n\t});\r\n\t\r\n\tw.add(b);\t\r\n\tw.open();\t\r\n})();\r\n{code}\r\n\r\nSteps to reproduce:\r\n\r\n1) Launch app and check memory used (aprox 16mb)\r\n2) Click the button to open the new window with the webview\r\n3) Close the window with back button and check memory used (22mb)\r\n4) Repeat steps 1-3. Every time window with webview is opened and closed,\r\nmemory used is increased by aprox 1mb.\r\n", "attachment": [], "flagged": false, "summary": "Android: Memory leak in Ti.UI.WebView", "creator": { "name": "javierfp81", "key": "javierfp81", "displayName": "javier ferrero", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK 3.0.0.GA and 3.1.0\r\nAndroid 2.3 and 4.0\r\n", "comment": { "comments": [ { "id": "241552", "author": { "name": "javierfp81", "key": "javierfp81", "displayName": "javier ferrero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Adding another example that demonstrates the memory leak. Now adding the webview directly to the main window:\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor : 'white'\r\n});\r\nvar webview = null;\r\nvar btnAdd = Ti.UI.createButton({\r\n title : 'Add',\r\n top : 0,\r\n left : 0,\r\n height : 50,\r\n width : 100\r\n});\r\nbtnAdd.addEventListener('click', function() {\r\n webview = Ti.UI.createWebView({\r\n \thtml : 'sample html',\r\n //url : 'local_webview.html',\r\n //url : 'http://www.google.com',\r\n height : 200,\r\n bottom : 10\r\n }); \r\n win.add(webview);\r\n});\r\nvar btnRemove = Ti.UI.createButton({\r\n title : 'Remove',\r\n top : 0,\r\n right : 0,\r\n height : 50,\r\n width : 100\r\n});\r\nbtnRemove.addEventListener('click', function() {\r\n win.remove(webview);\r\n webview = null;\r\n});\r\nwin.add(btnAdd);\r\nwin.add(btnRemove);\r\nwin.open();\r\n{code}\r\n\r\nTested in 2.0.2.GA, 3.0.0.GA and 3.1.0", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-03-11T13:32:16.000+0000", "updated": "2013-04-02T13:47:55.000+0000" }, { "id": "245148", "author": { "name": "soumyakantikar", "key": "soumyakantikar", "displayName": "Soumya Kanti Kar", "active": true, "timeZone": "America/Havana" }, "body": "We need to call webView.release() while closing the window to release the memory related to webview in Android. http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.WebView-method-release\r\n\r\nBut in the example, we are not calling this API. Don't we need to call this API?", "updateAuthor": { "name": "soumyakantikar", "key": "soumyakantikar", "displayName": "Soumya Kanti Kar", "active": true, "timeZone": "America/Havana" }, "created": "2013-04-02T06:35:20.000+0000", "updated": "2013-04-02T06:35:20.000+0000" }, { "id": "245291", "author": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Calling webView.release() helps in general. However TiWebViewBindings are still leaking.\r\nBut everything is being released when related Activity is destroyed.", "updateAuthor": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-02T21:56:50.000+0000", "updated": "2013-04-03T17:43:18.000+0000" }, { "id": "250180", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've tried both test cases multiple times and I can't reproduce the memory leak here. Occasionally I see the memory build up a little when going back and forth, but it eventually goes back down. I opened over 10 webviews, and when I look at the heap dump, I see 0-3 instances of the webview being retained. Keep in mind that this number will vary depending on GC lag. There's no guarantee that the webviews will be cleaned up as soon as you hit the gc button in ddms.\r\n\r\nGoing to mark this as cannot reproduce. Feel free to reopen if there is further information that can help reproduce this issue.", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-03T22:44:19.000+0000", "updated": "2013-05-03T22:44:19.000+0000" }, { "id": "414555", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as the issue cannot be reproduced and due to the above comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T22:15:26.000+0000", "updated": "2017-03-21T22:15:26.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }