[TIMOB-7152] iOS: Memory Leak: Objects created in a Ti.UI.tabGroup are not released when the tabGroup is closed
GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-07-06T00:43:30.000+0000 |
Affected Version/s | Release 1.8.0.1 |
Fix Version/s | Sprint 2012-04, Release 2.0.0, Release 2.1.0, Release 1.8.2 |
Components | iOS |
Labels | module_memory, qe-testadded |
Reporter | Francisco Antonio Duran Ramirez |
Assignee | Max Stepanov |
Created | 2012-01-12T17:09:44.000+0000 |
Updated | 2012-07-06T15:52:59.000+0000 |
Description
Problem
Objects created in a Ti.UI.tabGroup are not released when the tabGroup is closed.
Reproducible steps:
1. Run the code below.
2. Use the instruments application to monitor the memory
3. Click on Open tabgroup button
4. Click on close button
Please see TiUITabproxy on the category. It is never released from the memory.
Expected behavior:
Customer wants to release the memory of a tab.
Tested with the next specs:
Simulator
iPhone 4
Version of the device: 5.0.1
Titanium Studio, build: 1.0.8.201112291658
Titanium SDK: 1.8.0.1
More info:
Please see the video attached.
Code:
{Code}
function createTabGroup()
{
var colors = ['#ff9966', '#99ff66', '#6699ff', '#66ffff', '#ffff66'];
function openWindowOnStack(i)
{
var win = Ti.UI.createWindow(
{
title : 'Window ' + i,
backgroundColor : colors[i]
});
win.addEventListener('open', function(evt)
{
Ti.API.info('Opened: ' + evt.source.title);
if(i < 4)
{
setTimeout(function()
{
openWindowOnStack(i + 1);
}, 500);
}
});
win.addEventListener('close', function(evt)
{
Ti.API.info('Closed: ' + evt.source.title);
trackClosedWindow(tab1, evt.source);
});
openInTab(tab1, win);
}
var navButton = Ti.UI.createButton(
{
title : 'Open Windows'
});
var outer = Ti.UI.createWindow(
{
title : 'Root Window',
backgroundColor : '#d0d0d0',
rightNavButton : navButton
});
outer.rightNavButton.addEventListener('click', function()
{
openWindowOnStack(0);
});
function trackClosedWindow(thistab, window)
{
var windows = thistab.windows || [];
for(var w = windows.length - 1; w >= 0; w--)
{
if(windows[w] == window)
{
windows[w] = null;
windows.splice(w, 1);
break;
}
}
thistab.windows = windows;
}
function closeAllInTab(thistab)
{
var windows = thistab.windows || [];
for(var w = 0; w < windows.length; w++)
{
windows[w].close();
windows[w] = null;
}
thistab.windows = windows = [];
}
function openInTab(thistab, window)
{
var windows = thistab.windows || [];
windows.push(window);
thistab.open(window);
thistab.windows = windows;
}
var tabGroup = Ti.UI.createTabGroup();
var tab1 = Ti.UI.createTab(
{
window : outer,
title : 'Touch Me'
});
tabGroup.addTab(tab1);
var button2 = Ti.UI.createButton(
{
title : 'close',
height : 35,
width : 200
});
outer.add(button2);
button2.addEventListener('click', function(e)
{
outer.remove(button2);
outer.rightNavButton = null;
button2 = null;
navButton = null;
closeAllInTab(tab1);
tabGroup.removeTab(tab1);
tab1.window = null;
tab1 = null;
tabGroup.tabs = null;
tabGroup.close();
tabGroup = null;
outer.close();
outer = null;
Ti.API.info('Closed tab group');
});
return tabGroup;
}
var win1 = Ti.UI.createWindow(
{
backgroundColor : '#fff',
title : "Home"
});
var button1 = Ti.UI.createButton(
{
title : 'Open tabgroup',
height : 35,
width : 200
});
button1.addEventListener('click', function(e)
{
var tabGroup1 = createTabGroup();
tabGroup1.open();
Ti.API.info('Opened tab group');
});
win1.add(button1);
win1.open();
{Code}
Helpdesk
APP-443889
Attachments
Has there been any progress made on this issue? I would very much like to see this fixed as well.
Failing as PR 1474. Repo steps: 1. Profile ticket code 2. "Open Tabgroup" 3. -> Note 1 TiUITabGroupProxy 4. "Open Windows" 5. Either: 5a. Click back through the nav back button 5b. Click the tab to return to the main window 6. "Close Tabgroup" *PASS*: No
TiUITabGroupProxy
orTiUITabProxy
objects in memory *FAIL*: Otherwise *NOTE*: When clicking back through the nav back buttons, note that *none* of theTiUIWindowProxy
objects are released (although they are when you click the tab). This is another memory leak.Closing bug. Verified fix on: SDK build: 2.0.0.v20120315123246 Titanium Studio, build: 2.0.0.201203142055 xcode: 4.2 Device: iphone 4s (5.0.1) Note to QE: It takes a while for the last TiUITabGroupProxy object to be released on device.
Reopening/closing to add/remove labels
Both TiUITabGroupProxy and TiUITabProxy objects are not being released Tested with Titanium SDK: 2.1.0.v20120627151616 Tested with Titanium Studio: 2.1.0.201206251749 Devices: iphone 3GS(5.0.1) OS: OSX 10.7.3 This was working fine on 2.1.0.v20120625134154 and 2.0.2
*Verified this is indeed not working on iOS 5.0+ devices but is working on 4.X devices.* The Tab group is still visible on device on 5.0+ devices, while it is removed on 4.X devices Tested with Ti Studio build 2.1.0.201206251749 Ti Mobile SDK 2.1.0.v20120627151616 hash r87081627 OSX Lion 10.7.3 iPhone 4S OS 5.0.1 (Fail) iPhone 3GS OS 4.3.5 (Pass)
Tested with Ti Studio build 2.1.0.201206251749 Ti Mobile SDK 2.1.0.v20120628121617 hash r6e3cab6a OSX Lion 10.7.3 iPhone 4S OS 5.0.1, iPhone 3GS OS 4.3.5 Verified that the expected behavior is shown. *Note* It can take a few minutes for the proxy to be released
Re-opening to edit labels.