Linux memory leak?

Thiago Milczarek Sayão thiago.sayao at gmail.com
Wed Aug 7 16:57:32 UTC 2024


Hi,

There are some tips in this post (I've never tried them). GTK related
environment variables generally work.
https://stackoverflow.com/questions/16659781/memory-leaks-in-gtk-hello-world-program

valgrind and java:
https://stackoverflow.com/questions/9216815/valgrind-and-java


-- Thiago


Em qua., 7 de ago. de 2024 às 13:20, <quizynox at gmail.com> escreveu:

> Hello,
>
> Through developing JavaFX apps on Linux (X11, KDE) I always see the
> pattern when process (native?) memory doesn't get released back to the OS.
>
> 1. when app starts, the Java process consumes a relatively small amount
> of RAM (I track this via top or DE system monitor), usually around 120Mb.
> 2. if you do any manipulation with Stage (like resize it several times,
> or open the context menu several times) the memory process usage goes up
> to 130Mb.
> 3. then comes GC, which collects some _heap_ memory and returns it back
> to the OS depending on JVM settings, let say -5Mb
> 4. I repeat step 2, and JVM process process usage goes up again, +10Mb
> 5. again GC collects some _heap_ memory and uncommits it back to OS, -5Mb
>
> I have profiled the application with JDK 21 / JavaFX 21 and the
> following settings:
> -Xms32m
> -Xmx64m
> -XX:+UseZGC
> -XX:+ZUncommit
> -XX:ZUncommitDelay=30
>
> Heap is not a problem, it's always ~20-30MB.
> Metaspace is not a problem either, it's always around 2-4MB.
>
> It looks like native (stack, thread?) memory leaks, so never returned to
> the OS. I've never seen JavaFX app process memory usage return (not even
> close) to the same value it started with. RAM usage increases gradually
> and can be 1.5, 2, 3 times the initial value. Yet the heap usage never
> rises above the -Xms value.
>
> I run the same application (it's basically an empty stage) on Windows
> and see no such behavior. Process memory usage returns back to initial
> value almost immediately. Also, on Windows the JVM is freeing memory
> even without using ZGC.
>
> How should I profile this? Any hints?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20240807/bf1e0344/attachment.htm>


More information about the openjfx-dev mailing list