https://kotlinlang.org logo
Title
t

Trey

06/02/2022, 7:47 PM
I'm trying to use CIO and I'm just getting around to running my iOS app. I'm seeing this illegal state exception and I'm wondering if there is a flag I'm missing that will allow me to use it? Should I not use it all until it gets out of the experimental phase?
Caused by: kotlin.IllegalStateException: This API is only supported for experimental K/N memory model
    at 0   shared  0x0000000103c17eec kfun:kotlin.Throwable#<init>(kotlin.String?){} + 96
    at 1   shared  0x0000000103c10f80 kfun:kotlin.Exception#<init>(kotlin.String?){} + 92
    at 2   shared  0x0000000103c111b4 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 92
    at 3   shared  0x0000000103c117cc kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 92
    at 4   shared  0x0000000103ecb730 kfun:kotlinx.coroutines#newSingleThreadContext(kotlin.String){}kotlinx.coroutines.CloseableCoroutineDispatcher + 236
    at 5   shared  0x00000001040d9f28 kfun:io.ktor.network.selector.WorkerSelectorManager#<init>(){} + 192
    at 6   shared  0x00000001040d76c8 kfun:io.ktor.network.selector#SelectorManager(kotlin.coroutines.CoroutineContext){}io.ktor.network.selector.SelectorManager + 132
    at 7   shared  0x00000001040f20d8 kfun:io.ktor.client.engine.cio.CIOEngine.<init>$lambda-1#internal + 152
    at 8   shared  0x00000001040f3778 kfun:io.ktor.client.engine.cio.CIOEngine.$<init>$lambda-1$FUNCTION_REFERENCE$3.invoke#internal + 132
    at 9   shared  0x0000000103c46034 kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.getOrInit#internal + 760
    at 10  shared  0x0000000103c4672c kfun:kotlin.native.concurrent.FreezeAwareLazyImpl#<get-value>(){}1:0 + 524
    at 11  shared  0x00000001040f068c kfun:io.ktor.client.engine.cio.CIOEngine.<get-selectorManager>#internal + 256
    at 12  shared  0x00000001040efb08 kfun:io.ktor.client.engine.cio.CIOEngine#<init>(io.ktor.client.engine.cio.CIOEngineConfig){} + 1540
l

Landry Norris

06/02/2022, 7:51 PM
You can only use the new memory model with CIO
kotlin.native.binary.memoryModel=experimental
kotlin.native.binary.freezing=disabled
I’ve been using the new mm for months with no issues. I switched over during the first dev preview in 1.6
t

Trey

06/02/2022, 7:52 PM
Can you point me to the docs on how to switch to the new memory model. I assume there is more to it than those two lines?
t

Trey

06/02/2022, 7:52 PM
Sweet! Thank you
l

Landry Norris

06/02/2022, 7:53 PM
Should just be the two lines. There’s more you can add if you want to debug the mm in that article.
👍 1
I would also add
kotlin.native.cacheKind=none
for now, since caching can be iffy with the new mm right now.
👍 2