[OH4] Memory usage, Garbage Collection, is this observation correct?

Plattform: Raspi 4 ( 4GB )
OS openhabian
OH 4.0.2 Release Build

I am monitoring the memory usage of OH using the System Info binding.
The used memory for OH4 did increase as compared to OH3. I do understand that a constant increase is also considered normal, however the “Garbage Collection” should release parts of the memory if a certain amount has been reached (which ?).
I do see such behaviour ( kind of) in the attached chart. What makes me wonder is that the used amount does not level off, it seems to continue although some parts of the memory got relesed.
Do I need to be more patient to see such a level off?

Graph you see shows a memory leak which will eventually lead to out of memory error.

Thanks, I will investigate and report.

Hi Jürgen,
did you fond a solution for that used memory growth?
I think I have the same issue since OH 4 on RP4 (4GB).
The memory usage is growing until OH reboots!
In my case it took about 9 days.
In some articles I read about chaning some memory settings for Java like:
EXTRA_JAVA_OPTS=“-Xms192m -Xmx768m -XX:+ExitOnOutOfMemoryError”

I could not find the reason for the growing memory-usage (yet). In my case it would take weeks until the system would automatically reboot.
I have a Raspi4 with 4Gb RAM After running for about 8 days the GarbageCollection was decreasing the used memory once. The next GarbageCollection was coming after 3 more days. Actually I am at 24% of used memory.
Finding the culprit binding will rake long, I don’t think its coming from.core as that would raise more reports in here.

My used bindings:
Tankerkoenig
SystemInfo
MQTT
HTTP
Amazon Echo Control
Hue
Network
Sonos
Java Scripting
Smarthome/J Viessmann
OpenHAB Cloud
RRD4J

With OH 3.x I had some weeks before the memory was full.
That changed with OH 4. I did not change much of my configuration. There are some changes in the used Java version, now 17.
I had to change some of my scripts and roles due to changes in Java Script.
But anyway.
Is there a way of checking what process slowly filles up the memory.
For now I use: “htop” to check the memory in the console. I can see wtih the Tree view (I think) the single VM created by OH. Unfortunately they all show the same VIRT memory.
Jürgen, you talk about GarbageCollection! It this your local Garbage plan or an openhab internal cleaning procedure?
Is it something I can modify?

I was talking about the GarbageCollection of Java.
I have no real clue how to directly check where the memory leak is. The only way I know of is to either start openHAB with no binding / extension / rule installed and step by step import them and look if the problem is observed or do it the other way around ( i.e. removing the bindings from a fully installed system). The problem is how to “see” the problem because the system needs to be at a state where the periodic GarbageColkection takes place ( on my system.after a week).

Ok, I will try to find out more.
Maybe someone else has an idea on how to check why the memory fills up. I don’t like the idea of disabling binding by binding and check how it performs. That seems to be quite time consuming.

If you get a heap dump (there is a JVM option which triggers heap dump on memory error) you can browse its contents with JProfiler or similar software. Its a bit painful to do with remote machine, but its definitely be doable. Most interesting part of heap dump are objects retained over time. Probably one of OH related classes causes retaining of data for too long (or one of memory queue fills up).