Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19261

Android: Ti.Network.createHTTPClient memory leak

    Details

    • Type: Bug
    • Status: Open
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Environment:

      OS X 10.10.2, Titanium SDK 3.5.0, Alloy 1.5.1

    • Sprint:
      2018 Sprint 16 SDK, 2016 Sprint 17 SDK, 2018 Sprint 18 SDK, 2018 Sprint 19 SDK, 2018 Sprint 20 SDK, 2018 Sprint 21, 2018 Sprint 22

      Description

      Using the testcase below objects keeps building up (thus increasing heap size) and never gets released.

      To test open a new alloy project in titanium and edit tiapp.xml so it's debuggable and can be analyzed in Android Monitor.

      index.xml

      <Alloy>
      	<Window class="container">
      		<Label id="label" onClick="doClick">Hello, World</Label>
      	</Window>
      </Alloy>
      

      index.js

      function doClick(e)
      {
          Alloy.createController('testHTTP').getView().open();
      }
      $.index.open();
      

      testHTTP.xml

      <Alloy>
      	<Window id="container">
      		<Label text="test http" onClick="close"></Label>
      	</Window>
      </Alloy>
      

      testHTTP.js

      var url = "http://www.appcelerator.com";
      var xhr = Ti.Network.createHTTPClient();
      xhr.onload = function(e)
      {
          console.log('succes');
          xhr = null;
      };
      xhr.onerror = function(e)
      {
          console.log('error');
          xhr = null;
      };
      xhr.open("GET", url);
      xhr.send();
       
      function close()
      {
          $.container.close();
      }
       
      var topView = $.getView();
      for (var i=0;i<300;i++)
      {
          topView.add(
              $.UI.create('Label',{
              text:'Test label '+i,
              top:5,
              color:'#fff',
              font:{fontSize: '10'}
          })
          );
      }
      

      To test open the testHTTP window many times and watch how objects increase. In Android Monitor press "Cause GC" from time to time. Waiting to see if the automatic GC picks it up does not make a difference.

      The example code is simple but as soon as the page opened gets more complex the number of objects/heap size increases faster and eventually leads to an app crash.

      Note. I've tested this on my Galaxy S3 with Android 4.3

        Attachments

          Activity

            People

            • Assignee:
              gmathews Gary Mathews
              Reporter:
              andersdp Anders Dahl Pape
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Source Code