Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8172] Android: memory leaks opening/closing tabGroups

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-02T12:27:07.000+0000
Affected Version/sRelease 2.0.0, Release 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-07
ComponentsAndroid
Labelsapi, module_memory, qe-port
ReporterFederico Casali
AssigneeHieu Pham
Created2012-03-21T17:08:11.000+0000
Updated2013-01-18T14:53:27.000+0000

Description

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

Attachments

FileDateSize
leaksAndroidLog.txt2012-03-21T17:08:11.000+00008452

Comments

  1. Athanasios Nikolaou 2012-03-27

    Is there any progress in this issue???
  2. Neeraj Gupta 2012-03-27

    We are looking at this issue right now and should have a fix in next few days.

JSON Source