https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

Bradleycorn

02/07/2023, 8:20 PM
I’ve got a singleton with a variable:
Copy code
object MyObject {
    private var myVar: SomeObject? = null
}
and during a build I get:
i: file: <path to the file> With old Native GC, variable in singleton without @ThreadLocal can’t be changed after initialization
I’m using 1.8.0, and I thought the new memory manager is used by default since 1.7.20 … ???
👆 1
j

jw

02/07/2023, 8:33 PM
You can still opt-out, and that can happen downstream outside your control.
b

Bradleycorn

02/07/2023, 8:54 PM
@jw thanks for the info. I haven’t opted out myself, but perhaps it is something downstream. I’m seeing this in my database module, which is leveraging sqldelight 1.5 … Perhaps that is using the old memory management? Looks like support for the new memory model was added in 2.0.0-alpha03
j

jw

02/07/2023, 9:07 PM
I'm saying that during compilation of your module you cannot know what memory model will be in use at runtime
h

Hylke Bron

02/08/2023, 7:06 AM
Does this mean that when you're writing a KMM library that depends on the new memory model, it is wise to put a runtime check that makes sure the correct memory model is used so you can give a better error message in case a consumer of your library by accident uses the legacy memory model?
b

Bradleycorn

02/08/2023, 6:02 PM
Ooooooh, I see what you’re saying now, duh. And that’s why the build message is “info” and not warning or error.
54 Views