https://kotlinlang.org logo
Title
r

ribesg

02/16/2022, 2:10 PM
Does the normal version of Ktor support the new Kotlin Native Memory Management Model from 1.6.3+? I don’t see anything in the changelog
b

Big Chungus

02/16/2022, 2:20 PM
What do you mean by normal?
r

ribesg

02/16/2022, 2:21 PM
As opposed to the eap 1.6.2 version which was specifically made for the new memory model, after that I can’t find anything about it in subsequent versions
b

Big Chungus

02/16/2022, 2:22 PM
Are you talking about ktor client?
r

ribesg

02/16/2022, 2:23 PM
Well yeah in my case
But you can also use the server in K/N so it shouldn’t matter
b

Big Chungus

02/16/2022, 2:23 PM
I think you should be fine with new mm. Ktor server in k/n is not released yet and will only come with 2.0
r

ribesg

02/16/2022, 2:24 PM
Thanks, I’ll try the new mm then
m

Michal Klimczak

02/16/2022, 2:43 PM
I am trying to make the 2.0 client work with new memory model and having some troubles. Right now it's
InvalidMutabilityException: mutation attempt of frozen kotlin.Array@249bab0
in
kfun:io.ktor.client.plugins.json.serializer.SerializerInitializer.<init>#internal + 236
. (trying to install kotlinx serialization into ktor) Using coroutines 1.6.0-native-mt fwiw (in regular 1.6.0 had other issues). (works without new-mm flag)
r

ribesg

02/16/2022, 3:21 PM
I’m pretty sure coroutines
1.6.0-native-mt
isn’t meant to work with the new memory model
h

hfhbd

02/16/2022, 3:23 PM
Coroutines
1.6.0-native-mt
works with the new MM. Problems are external dependencies, like
io.ktor.client.plugins.json
, which uses a shared Json instance
m

Michal Klimczak

02/16/2022, 3:33 PM
I put my own Json instance to the plugin. This happens at the very startup of the app, the first time the ktor client is created with the json plugin. Any hints what can be done about it?
m

Michal Klimczak

02/16/2022, 3:57 PM
🤔 I'm not using the defaults so that should not affect my code.
okay so I fixed it by removing
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
from my iosMain source set (was left after migration to ktor 2.x). But now I have
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.ktor.client.engine.engines.Node@3d40580
😄
okay, so the thing that fixes ktor and a few other things for me is
kotlin.native.binary.freezing=disabled
in
gradle.properties
a

Aleksei Tirman [JB]

02/17/2022, 2:18 PM
What exact version of Ktor do you use?
m

Michal Klimczak

02/17/2022, 4:16 PM
2.0.0-beta-1