Problem
Memory leaks when opening and closing a window including a tabGroup
Code and steps to reproduce
var mainwin = Ti.UI.createWindow({
title:'TEST WINDOW',
backgroundColor:'#fff',
fullscreen:true,
statusBarHidden: true,
navBarHidden:true,
exitOnClose:true
});
var button = Ti.UI.createButton({
title: "create tabGroup"
});
var MY_TABGROUP = null;
Titanium.App.addEventListener('tabGroupclosed', function(e) {
Ti.API.debug('MY_TABGROUP close...');
MY_TABGROUP = null;
});
button.addEventListener('click', function(e) {
MY_TABGROUP = require('/myNewTabGroup').innerTabGroup();
MY_TABGROUP.open({
animated: true
});
});
var button2 = Ti.UI.createButton({
bottom: 200,
title:'show MY_TABGROUP'
});
button2.addEventListener('click', function(){
alert(MY_TABGROUP)
});
mainwin.add(button2);
var button3 = Ti.UI.createButton({
bottom:5,
title:'GC'
});
button3.addEventListener('click', function(){
views1 = [];
views2 = [];
MY_TABGROUP=null;
});
mainwin.add(button3);
mainwin.add(button);
mainwin.open();
exports.innerTabGroup = function() {
var tabGroup = null;
var win1 = null;
var tab1 = null;
var win2 = null;
var tab2 = null;
var views1 =[];
var view1 = null;
var views2 =[];
var view2 = null;
tabGroup = Titanium.UI.createTabGroup();
win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
for (var i=0; i < 600; i++) {
view1 = Ti.UI.createView();
views1.push(view1);
win1.add(view1);
}
tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
for (var i=0; i < 600; i++) {
view2 = Ti.UI.createView();
views2.push(view2);
win2.add(view2);
}
tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
return tabGroup;
};
Steps followed with allocated memory and # of objects:
1. Run the app (memory 3144MB - #Objects 60,139) and click on 'create tabGroup' button (mem 8053 - Obj 148,156)
2. Hit back button (mem 4457 - 91,059). Reference to MY_TABGROUP is still present and is still not GC
3. Click the GC button to set MY_TABGROUP to null (mem 4234 - Obj 86,654)
4. Click on create tabGroup button (mem 9007 - 172,396)
5. Hit back button (5408 - 115,292)
Memory increase in size subsequently repeating the steps.
Attaching also the log file.
Additional info
Customer ticket:
http://support-admin.appcelerator.com/display/APP-355811
Is there any progress in this issue???
We are looking at this issue right now and should have a fix in next few days.