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.
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.
To force JS GC on a device: press Home button, launch another app (Stocks/Clock), return back to the app.
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
Reopening to fixversion
Reopening/closing to add/remove labels