Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 1.8.2
    • Fix Version/s: Release 2.1.0
    • Component/s: Android
    • Environment:
      • Titanium SDK version: 2.0.0 (03/22/12 23:17 bc1a32c)
      • v8
      • Android 3.1 (on Thinkpad Tablet device)
      • Windows XP

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                joshroesslein Josh Roesslein
                Reporter:
                ivan.skugor Ivan Skugor
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-12643
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration