Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7642] iOS: Memory Leak when local html file is used in a WebView

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-19T13:19:58.000+0000
Affected Version/sRelease 1.8.1
Fix Version/sSprint 2012-04, Release 2.0.0, Release 1.8.3
ComponentsiOS
Labelsmemory, module_webview, qe-testadded, webview
ReporterSandeep Bhimavarapu
AssigneeMax Stepanov
Created2012-02-13T19:07:37.000+0000
Updated2012-04-19T13:19:58.000+0000

Description

Memory is not being released when a webview, with a local HTML file, is added to a window and then removed from it. But this does not happen when a remote URL is used. Below is the sample code and the local HTML file has been attached. *Sample Code* {noformat} var win = Ti.UI.createWindow({ backgroundColor : 'white' }); var webview = null; var btnAdd = Ti.UI.createButton({ title : 'Add', top : 0, left : 0, height : 50, width : 100 }); btnAdd.addEventListener('click', function() { webview = Ti.UI.createWebView({ url : 'local_webview.html', // url : 'http://www.google.com', height : 200, bottom : 10 }); win.add(webview); }); var btnRemove = Ti.UI.createButton({ title : 'Remove', top : 0, right : 0, height : 50, width : 100 }); btnRemove.addEventListener('click', function() { win.remove(webview); webview = null; }); win.add(btnAdd); win.add(btnRemove); win.open(); {noformat} *STEPS TO REPRODUCE* - Drop the above sample code into app.js and copy the attached 'local_webview.html' to Resources folder. - Start the application and open Instruments to profile it. - Click the 'Add' button and then the 'Remove' button. - Search for 'proxy' in instruments and it can be seen that webview proxies are not released even if memory warnings are simulated. *EXPECTED BEHAVIOR* Proxies related to webview should be released. *OBSERVED BEHAVIOR* Memory is not being freed. *OTHER OBSERVATIONS* Memory is being freed when a remote URL (uncomment the line with google.com and comment out the line with local_webview.html) is used.

Attachments

FileDateSize
local_webview.html2012-02-13T19:07:37.000+00001021

Comments

  1. Michael Pettiford 2012-03-19

    Reopening issue Tested with Ti Studio build 2.0.0.201203182248 Ti Mob SDK 2.0.0.v20120319003254 hash r60b6da4c OSX Lion 10.7.3 iPhone 4 OS 5.0.1 I'm still seeing the fail case as noted in the ticket. When I change the url it works as expected.
  2. Max Stepanov 2012-03-19

    To force JS GC on a device: press Home button, launch another app (Stocks/Clock), return back to the app.
  3. Michael Pettiford 2012-03-19

    Closing issue Tested with Ti Studio build 2.0.0.201203182248 Ti Mob SDK 2.0.0.v20120319003254 hash r60b6da4c OSX Lion 10.7.3 iPhone 4 OS 5.0.1 *Note that in instruments > allocations hit the info button and deselect the option for only track active allocations* Verified that the proxy is being released
  4. Stephen Tramer 2012-03-29

    Reopening to fixversion
  5. Michael Pettiford 2012-04-19

    Reopening/closing to add/remove labels

JSON Source