I am using Ktor darwin-legacy (2.3.9) for my KMP i...
# ktor
t
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
Are you able to reproduce the leaks with the non-legacy artifact (
ktor-client-darwin
)?
t
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.
Untitled
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:
Copy code
MainScope().launch {
    withContext(Dispatchers.Main) {
         callSuspendAPIMethod()
    }
}
Perhaps I am doing something wrong here - I am no coroutines expert...
a
Does it leak if you use a dispatcher other than
Dispatchers.Main
?