https://kotlinlang.org logo
#ktor
Title
# ktor
q

quiqua

07/18/2019, 2:05 PM
For a
HttpClient
provided by ktor - can it be used as a singleton or should new requests made with different instances ?
We currently have a
kodein
configuration to use a singleton
bind<HttpClient>() with singleton { HttpClient(OkHttp) }
, but are also confronted with a memory leak in our app and I currently suspect the HttpClient 🤔
e

e5l

07/18/2019, 2:11 PM
Hi @quiqua, you can create multiple clients if you want to, but you also can use single
q

quiqua

07/18/2019, 2:13 PM
Alright, then it might be a different issue within the project 🙂 Thanks for the quick heads up.
is the
HttpResponse.close
method called automatically or is it my responsibility to do so at some part of the code execution?
e

e5l

07/18/2019, 2:28 PM
You should call
close
manually or with
response.use { }
method
q

quiqua

07/18/2019, 2:30 PM
thanks 🙂
6 Views