Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27851] iOS: Ti.Network.createHTTPClient memory leak

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-05-05T21:09:58.000+0000
Affected Version/sRelease 9.0.0
Fix Version/sRelease 9.0.2
ComponentsiOS
Labelsn/a
ReporterJoe Finnigan
AssigneeVijay Singh
Created2020-04-16T11:40:50.000+0000
Updated2020-05-05T21:09:59.000+0000

Description

Description

HTTPClient is leaking memory causing an eventual crash, appears to have only been introduced in 9.0.0.GA, could be regression on this issue: TIMOB-26811

How to reproduce

This sample will fire 20 url fetches every 1 second, it clearly shows the memory leak in xcode instruments. Do not run for long too long... Index.js
var triggerLoop = function() {
  _.times(20, fetchUrl);
};

function fetchUrl() {
      var client = Ti.Network.createHTTPClient({
        onload: function(e) {
            client = null;
        },
        onerror: function(e) {
          client = null;
        },
        timeout: 1000
      });
      client.open(
        "GET",
        "https://example.com/"
      );
      client.send();
      console.log("Fetching Url");
}

setInterval(triggerLoop,1000);
If you monitor with xcode leaks profiler, you will see a large amount of leaks from CFNetwork, I have attached the screenshots of profiling tool results.

Attachments

FileDateSize
Screenshot 2020-04-16 at 12.19.54.png2020-04-16T11:38:44.000+000057597
Screenshot 2020-04-16 at 12.20.01.png2020-04-16T11:38:45.000+0000316150

Comments

  1. Satyam Sekhri 2020-04-16

    I could reproduce the leak as mentioned in the details using the test code provided. However the issue doesn't seems to be a regression in 9.0.0.GA. Using the same test app similar leaks at a similar rate were observed in older SDK builds as well. Tried with titanium SDK build 9.0.0.GA, 8.3.1.GA, 8.3.0.GA and 8.0.0.GA Verified on: Mac OS: 10.15.4 Appc CLI: 8.0.0, 7.1.2 Node: 10.16.3 Studio: 6.0.0.202003181504 Xcode: 11.4, 11.2.1 iOS Device: iPhone 7(v12.4.5)
  2. Joe Finnigan 2020-04-17

    The app that I discovered this in was previously using Ti SDK 8.0.1.v20190326110553 and didn't exhibit the leak, granted not running this exact test code but its very close.
  3. Vijay Singh 2020-04-20

    PR (master) - https://github.com/appcelerator/titanium_mobile/pull/11649 PR (9_0_X) - https://github.com/appcelerator/titanium_mobile/pull/11650 PR (app_sdk) - https://github.com/appcelerator/aps_sdk/pull/343
  4. Hans Knöchel 2020-04-24

    Can you please provide a bit of insight on which version caused the regression? It's important for knowing if we're affected or not. Thank you!
  5. Satyam Sekhri 2020-04-28

    [~hknoechel] I tried as far back as 7.5.0.GA and could reproduce the leaks related to CFNetwork on 7.5.0.GA as well using the test code in the ticket. Hope this helps.
  6. Satyam Sekhri 2020-04-28

    FR Passed
  7. Satyam Sekhri 2020-05-05

    No CFNetwork leaks seen. Verified on: Mac OS: 10.15.4 SDK: 9.1.0.v20200505112143, 9.0.2.v20200505111803 Appc CLI: 8.0.0 Node: 10.16.3 Studio: 6.0.0.202003181504 Xcode: 11.4 iOS Device: iPhone 7(v12.4.5), iPhone X(v13.4), iOS simulator 13.4

JSON Source