OH4 runs out of memory

Looking at your heap dump - it doesn’t seem to have memory issues, its fairly small (300 megs). From thread list however I can see a lot of WebSocketClient instances, way too much for a regular launch. Looking at references it seems to be related to the lgthinq binding. I can’t see anything wrong in its code for now. I could be blind or wrong (I prefer later!).

Edit: Second suspect place is shelly and its Shelly2RpcSocket. Looking at its code - there are multiple calls to close which is grateful shutdown of connection.
@cmachtel Heap dump contains 261 instances of websocket sessions. Do you have so many shelly devices?

Cheers,
Łukasz