So I've recenty started to use Compose Desktop (0....
# compose-desktop
d
So I've recenty started to use Compose Desktop (0.4.0build185) and even the template app causes the memory to rise every time the user clicks the button. Actually it seems like every time the UI is recomposed, the memory increases. It has reached over 1.4GB at times. Has anyone else seen this?
b
Are you sure that this is your application and not another?
j
@Dario Valdespino If you think you've found a memory leak in Compose-desktop, please file an issue on github with a minimal repro.
d
@Bogdan I'm pretty sure there's no other 'MainKt' running in my machine. Its weird, and I'm only asking here because I think it's too big of a bug to be real. However I'm not doing anything at all, it's just the template app with a button.
I didn't file an issue because I want to make sure this is not just me... But I already tried on Ubuntu 20.10 and MacOs BigSur, so...
b
well, there are usually several processes there: 1 IDEA 2 Gradle 3 Kotlin Compiler
message has been deleted
d
I know, but my app shows up as 'MainKt', Idea and such appear as 'java'
j
You can use
jps -m
to get a more detailed name of all the java processes.
it's too big of a bug to be real
The compose codepath can be very hot, especially if an animation is running or something similar. If there is an edge case with a small leak, it could add up fast. If you have a minimal repro that demonstrates the bug, please file a bug on github.
m
How did you examine the memory consumption? It is quite normal that the memory increases if you haven’t forced a full garbage collection. The GC does not automatically keep the memory at its minimum if there is no need for that.
d
Through the system monitor mostly. I made sure to manually trigger the GC while testing it. I thought about GC too at first, but 1.4GB of RAM for a program that only shows a button is too much!
I already filed the issue, In my case, to reproduce it you simply create a new Compose app with the project wizard and use Kotlin 1.4.32 and Compose 0.4.0-build185. That's it, the default app does that.
m
You should check that again with a tool like VisualVM for example. It depends on the garbage collector you use whether it returns memory to the system at all. If you allow it to use that much RAM it will happily use that and you will not see any decrease in the system monitor.
d
I'll try that, thanks for the tip. It must be something like that, the garbage collector not returning memory to the system. I'll have to look up how to limit the JVM's memory usage.
Well, VisualVM says the heap is just using 34MB and the metaspace about the same, so it seems that the freed RAM is not being returned to the system. I'll have to find out how to fix that. Thanks for the tip!