I am using Ktor darwin-legacy (2.3.9) for my KMP iOS app, and running Instruments I see what appear to be leaks on nearly every API call. Has anybody else seen this behavior, and perhaps there is a simple fix for it? I see a good number of bodyAsText along with other calls which makes me think any memory allocated to handle the response and parsing are the culprit. Thank you.
a
Aleksei Tirman [JB]
03/29/2024, 8:15 AM
Are you able to reproduce the leaks with the non-legacy artifact (
ktor-client-darwin
)?
t
tylerwilson
03/29/2024, 4:13 PM
I moved to use the 'regular' darwin (I use legacy because we need iOS !2 support in one of our apps). I debugged again and found one repeated leak caused by me (a custom HMAC SHA1 calculation). Changed that to use KotlinCrypto package, and that one is fixed.
Still see a repeated 4K leak on every call in Ktor though. See next text snippet.
Note: after looking in more detail, it appears the leak only appears for those network calls I am doing in a suspend function. I am calling something like: