Problem
I've noticed TabGroup memory leak. When local JS object has a property that references TabGroup, it never gets released.
Same test case that uses heavyweight Window instead of TabGroup does not have that problem.
Test case
Using TabGroup (produces memory leak)
(function() {
var create = function() {
var tabGroupWrapper = {}, tabWrapper = {}, winWrapper = {}, tableViewWrapper = {}, buttonWrapper = {};
tabGroupWrapper.Element = Ti.UI.createTabGroup();
winWrapper.Element = Ti.UI.createWindow({ navBarHidden: true, backgroundColor: '#fc9', layout: 'vertical' });
tabWrapper.Element = Ti.UI.createTab({ title: 'Test', window: winWrapper.Element });
tabGroupWrapper.Element.addTab(tabWrapper.Element);
tableViewWrapper.Element = Ti.UI.createTableView();
var data = [];
for (var i = 1; i <= 500; ++i) {
data.push({ title: 'Row ' + i});
}
tableViewWrapper.Element.setData(data);
buttonWrapper.Element = Ti.UI.createButton({
title: 'Create new tabgroup!'
});
buttonWrapper.Element.addEventListener('click', function() {
create();
});
winWrapper.Element.add(buttonWrapper.Element);
winWrapper.Element.add(tableViewWrapper.Element);
tabGroupWrapper.Element.setActiveTab(0);
tabGroupWrapper.Element.open();
};
create();
})();
Using Window (does not produce memory leak)
(function() {
var create = function() {
var winWrapper = {}, tableViewWrapper = {}, buttonWrapper = {};
winWrapper.Element = Ti.UI.createWindow({ navBarHidden: true, backgroundColor: '#fc9', layout: 'vertical' });
tableViewWrapper.Element = Ti.UI.createTableView();
var data = [];
for (var i = 1; i <= 500; ++i) {
data.push({ title: 'Row ' + i});
}
tableViewWrapper.Element.setData(data);
buttonWrapper.Element = Ti.UI.createButton({
title: 'Create new window!'
});
buttonWrapper.Element.addEventListener('click', function() {
create();
});
winWrapper.Element.add(buttonWrapper.Element);
winWrapper.Element.add(tableViewWrapper.Element);
winWrapper.Element.open();
};
create();
})();
Steps
To see this issue, run first test case, click on the button and then close tabgroup by using hardware back-button. Repeat that and observe heap size. You should notice that heap size increases and that memory is not being released.
On the other hand, by running second example (the one that uses Window) and doing the same thing (open -> back -> open ...) you should see that memory is being released.
Is there any progress in this issue please???
Seems it's forgotten. :(
Or not, thanks Neeraj. :)
Is there any progress in this issue please???
Should I be backing out of the application then relaunching it? There is no other window once the tab group window closes or a button to re-open the tab group.
Hello Josh. No, you should press "Create new tabgroup" button and then press hardware back-button and repeat that. But, now I tested again with latest CI build and this issue seem to be solved. So, it can be marked as resolved.
Closing as the issue can no longer be reproduced.
This issue has been resolved in 2.1.0 release. It probably was part of another fix.
Titanium Studio: 2.1.0.201206221045 Mobile SDK: 2.1.0.v20120622174154 OS: X Lion Device: Samsung Galaxy Can't reproduce. Find no changes memory leak information in VM Heap and any changes in Sys Info: Memory Pie chart.
Re-opening to edit label