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

Joakim Forslund

06/17/2022, 1:48 PM
Hi, I reported this https://youtrack.jetbrains.com/issue/KTOR-4297/aSocket-for-Native-Linux-is-leaking-if-host-and-port-is-unreachable and this https://youtrack.jetbrains.com/issue/KTOR-4298/embeddedServer-CIO-for-Native-Linux-with-[…]-serialization-kotlinx-json-seems-to-be-leaking-for-every regarding memory leaks some time ago, I can't publish my code into production, because the host also declines hosting the docker images because of leak detection as well, is something being done about this? Can I supply more information to help out?
a

Aleksei Tirman [JB]

06/17/2022, 2:02 PM
@e5l
n

napperley

06/18/2022, 4:09 AM
Once memory leaks are detected at the library level they need to be fixed ASAP. This isn't happening with the Native versions of the Ktor libraries (especially those that target linuxX64), and it is gradually getting worse with each new release. I don't think that the Ktor team is taking memory management issues very seriously.
😞 1
There isn't much point in using the Ktor libraries in production if the memory issues keep piling up, with no urgency to fix them.
j

Joakim Forslund

06/18/2022, 10:36 AM
While thankful for chiming in, in this case, I do not think these issues are to be blamed on the ktor team in particular, if one inspect the code reported by valgrind, there are great attempts to free the memory, even with extra measure as late invoked dispose.
The issue is the new memory model, somehow failing to free when it most likely sais it did so without problems
e

e5l

06/20/2022, 7:23 AM
Hey @napperley, could you hint me some issues you are talking about? I will take a look on how we can avoid this
🙏 1
n

napperley

06/21/2022, 1:59 AM
One of the issues that was encountered a long time ago is the Ktor Client library (targeting linuxX64) leaking memory every time a request (using a text payload) is made. I'm not sure if that issue has been fixed. Back when the library was being evaluated the decision was made to use the libcurl library ( https://curl.se/libcurl/ ) instead which doesn't have this issue. After the switch was made a discovery was found with libcurl where less reserved memory was used if multiple connections were utilized instead of reusing a single connection. Since the native version of Ktor Client is based on libcurl does it reuse a single connection, or are multiple connections utilized instead?
5 Views