Description
After upgrade sdk version from 6.3.0 to 7.4.1/7.5.0, IOS start to have a big memory leak issue when making api requests. The app is going to crash when memory are too high.
How to reproduce
I have create a simple app with only one api request which will be called every 10 seconds, you can build the app from
https://github.com/lukeluluke/simpleApp.git
1. Clone the project and build with sdk v7.5.0.GA
2. Use Instruments to monitor the memory usage and leaks
3. You will find the memory keep increasing , and the are memory leaks for almost each api request.
4. Rebuild the app with sdk v.6.3.0.GA.
5. Use Instruments to monitor the memory usage and leaks
6. You will see the is only one leak in the beginning
I have attached the screenshots of profiling tool
Update
I have upgraded xcode to latest version, and removed the setInterval function, memory leaks still exist when trigger api calls manually. Please see screenshots below.
I know this is not the correct project to report, but this is the only project I can select when creating the issue
[~luke_lu], Thanks for reporting this. Can you please try using the upper Xcode version 10/10.1 and let us know the results.
[~luke_lu], you are using
setInterval
to make the request. There is a known leak in 7.5.0.GA related to timers that was fixed in TIMOB-26688. This fix is included in the upcoming 7.5.1.GA release. You can already check it out viati sdk install -b 7_5_X
.For our production app, it has memory leaks and crash a lot since upgraded sdk from v6.3.0.GA to v7.4.1.GA. When we profiling the memory usage, we found memory will increase for each api request, that is why I use setInterval function to simulate multiple api requests.
[~luke_lu], Did you manage to check using ti sdk install -b 7_5_X?
I have tried 7_5_X and 8_0_X, memory leaks still exist. I have updated the test app's git repository, you can test the newest code. Thanks
Hello, Our engineering team verified the fix on SDK 8.0.0.v20190123061938 in branch 8_0_X. Can you try using the following version and let us know the results. *appc ti sdk install 8.0.0.v20190123061938*.
Hi Rakhi, i have installed 8.0.0.v20190123061938, but it doesn't help. I can still see the memory leaks by using Instruments. Please see attached screenshot. Can you please review the code of sample app (only a fews lines), are there something we need to do after make api calls. Thanks !v8.0.0.v20190123061938_memory_leak.png|thumbnail!
[~luke_lu], these look different then those from your previous example. I'll take a look!
Alright, after some comparison between 6.3 and 7.X it seems like we indeed leak some memory in our HTTP client. Moving this to TIMOB for further investigation.
PR: https://github.com/appcelerator/APSHTTPClient/pull/48
PRs to update the APSHTTPClient library in the SDK: PR (master): https://github.com/appcelerator/titanium_mobile/pull/10704 PR (8_0_X): https://github.com/appcelerator/titanium_mobile/pull/10705
PR (aps_sdk): https://github.com/appcelerator/aps_sdk/pull/332
[~ssekhri], add the following below [this line](https://github.com/lukeluluke/simpleApp/blob/e6c265c2dc0b7073a3da50feabb0ec2f616b4d6b/SimpleProject2/app/controllers/index.js#L22v) to force the HTTP client to get cleared immediately.
Otherwise it might take a while until the JS GC kicks in and actually deletes the client and all of its resources (including the leaking objects). You should now no longer see any leaks related to networking.
Ok, there still seems to be an issue with leaking objects. I tried with a forced garbage collection and in fact the leaks now only show after a GC. Giving this another pass tomorrow.
FR Passed. Merged to master and 8_0_X