Skip to content

Why Kotlin Desktop has so high memory usage? #2436

@BusyZzZz

Description

@BusyZzZz

Why does Kotlin Desktop use so much memory, for example in the standard "Hello World" project ganerated by IDEA?
I tested it only on Windows 10 and use compose version = 1.2.0, kotlin version = 1.7.20 and openjdk-19. I builded it with gradle to .exe app

import androidx.compose.material.MaterialTheme
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application

@Composable
@Preview
fun App() {
    var text by remember { mutableStateOf("Hello, World!") }

    MaterialTheme {
        Button(onClick = {
            text = "Hello, Desktop!"
        }) {
            Text(text)
        }
    }
}

fun main() = application {
    Window(onCloseRequest = ::exitApplication) {
        App()
    }
}

image
App at start:
image
134Mb
Just clicked the button and draged the window:
image
234Mb
Am I do something wrong or its just not optimized?
Seen same issue bellow: #1632, but kotlin updated since that time and I was hoping that situation was changed

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions