Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8286] Android: TabGroup memory leak

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-09T03:44:51.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 2.1.0
ComponentsAndroid
Labelsapi, module_tabgroup, qe-testadded
ReporterIvan Skugor
AssigneeJosh Roesslein
Created2012-03-23T01:04:54.000+0000
Updated2012-10-29T21:59:32.000+0000

Description

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.

Comments

  1. Ivan Skugor 2012-03-26

  2. Athanasios Nikolaou 2012-04-20

    Is there any progress in this issue please???
  3. Ivan Skugor 2012-05-09

    Seems it's forgotten. :(
  4. Ivan Skugor 2012-05-09

    Or not, thanks Neeraj. :)
  5. Athanasios Nikolaou 2012-05-14

    Is there any progress in this issue please???
  6. Josh Roesslein 2012-05-15

    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.
  7. Ivan Skugor 2012-05-16

    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.
  8. Josh Roesslein 2012-05-16

    Closing as the issue can no longer be reproduced.
  9. Neeraj Gupta 2012-05-22

    This issue has been resolved in 2.1.0 release. It probably was part of another fix.
  10. Payminder Singh 2012-06-23

    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.
  11. Shyam Bhadauria 2012-07-09

    Re-opening to edit label

JSON Source