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.
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)
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.
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
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!
[~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.
FR Passed
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