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

obobo

03/14/2019, 2:25 PM
If I use
JsonFeature
and make calls like
httpClient.get<DataClass>("url")
is the underlying httpResponse automatically closed, or does it expect me to close httpClient after each call? I haven't been able to find where the response is closed.
r

ribesg

03/14/2019, 2:38 PM
You’re creating an
HttpClient
for each call?
o

obobo

03/14/2019, 2:40 PM
No, that's the problem. I'm seeing a memory leak in an application -- we share the client between all calls. In the past I've used
get<HttpResponse>(...)
to get the response and close it myself. I'm looking at the transforming
get
call and it doesn't look like it closes the response after reading, so I'm wondering what the safe way to use that method is.
e

e5l

03/14/2019, 3:11 PM
Could it be related to this https://github.com/ktorio/ktor/issues/1009 ?
o

obobo

03/14/2019, 3:14 PM
I think it could be, yeah.
e

e5l

03/14/2019, 3:15 PM
The fix is complete and would be available soon.
r

r4zzz4k

03/14/2019, 7:24 PM
So in general it should be closed automatically, right?
e

e5l

03/14/2019, 7:28 PM
Yes
r

r4zzz4k

03/14/2019, 7:28 PM
Thanks for confirming!
👌 1