-
-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Measures to use less RAM by default #3875
Comments
This might be a nice place to add some of these flags: |
Very interesting. Your suggestions have to be validated by experts. Maybe we should propose two sets of settings, one for very small machines and one for others. PS: thread pools size could also be setup differently depending on how much RAM you have. |
Interesting - I would have guessed different. Pi 4 came out in June 2019 - that's over four years ago. @joerg1985 |
|
Based on the number of users who show up on the forum after upgrading to OH 4 and running out of RAM I'd say it is a significant portion of users who are still on RPi 3s. |
I was also struggling with memory issues recently due to the 1GB limit on older RPIs. What can also help is to increase the swap file size: https://pimylifeup.com/raspberry-pi-swap-file/ It will only work for applications that load a lot of stuff in memory which is infrequently used. If it continuously swaps pages to/from the swap file it can wear out your sdcard pretty quickly ofcourse. 😉 |
@wborn using zram might be an option to not swap to the sdcard. I am using zram with zstd compression and a 200% ratio on my 3a+ with 512 mb ram. |
I run OpenHab 4 with the following flags since I updated:
I have very good results on a Synology ARMv7 (this is a 32bit platform) with 1GB RAM. The heap of 384M is rarely used more than 50% (usually only 34%-43%), but then I also have only a very small number of items and rules and only very few bindings/add-ons (hue, livisi, system info, JS scripting, homekit). The Min/MaxHeapFreeRatio settings made a big difference as I want OpenHab to consume as little RAM as possible so that the Synology NAS can also perform its normal duties unaffected. I changed now to include |
Since OpenHAB 4, these are the flags I use:
A few notes:
I also have a rule to run a full GC every night when I am not using OH. This reclaims some extra memory from some instances that like to grow a bit more every few days.
inserted some randomness to avoid all OpenHAB instances running GC at the same exact time (probably not needed since it only takes a few milliseconds). A final note is that I compared the JVM memory when running OpenHAB4 in Docker Vs in the host, and there was no difference at all when using these settings. I mention this because I had read in the forum someone suggesting that the JVM consumes more memory in Docker, but according to my experiments this is not the case. |
I think that is a misreading of what was said and lacks context. The JVM isn't going to use any more or any less memory because it's running in Docker. The JVM isn't even going to know it's running in Docker. But the Docker container over all is going to consume more RAM than running openHAB on bare metal because there is additional overhead. |
@joerg1985 I've experimented with a standalone parser for thing syntax and got some results. My goal was literally bypassing whole complexity of xtext and emf. Its doable. I see you use JS for rules, is Rule DSL remain your concern? |
@splatch i was looking for low hanging fruits to reduce memory consumption. e.g. like PR openhab/openhab-addons#16379 |
I guess tweaking the JVM options will not be universaly good: for some users the changes will be good, for others bad. Moving more things from core to optional addons is the right way. What comes to my mind: voice things, Language server, DSL, Blockly. |
Sure enabling flags should be done with caution, e.g. like openhab/openhabian#1859 only for lowmem devices. |
I assume a significant amount of openHAB instances are running on single board computers.
These have usually a limited set of memory especially the Raspberry Pi 3 based.
For me openHAB 4.0.x runs successfully with some modifications on a Raspi 3a+ (512 MB).
I would like to share these to upstream these changes / find some other improvements.
Set
-Dxtext.qn.interning=true
or callQualifiedNameInterning#enable()
to intern the strings inside theQualifiedName
instances.This will remove a lot of Strings (~50%) from memory and could be exposed to the UI and the default setting could be enabled.
Disable
Use IPv6
inNetwork Settings
of openHAB to get rid of a second jmDNS instance.This might be a good default value for most users?
Set
-Xss1024k
, this will half the thread stack size from the 2048k defaultThis is a more advanced topic but could be documented somewhere.
openHAB is using 200+ threads and this has quite an impact
Set
-XX:+UseG1GC
and-XX:+UseStringDeduplication
to enable string deduplication on GC levelDo you think memory usage is an issue at all or are most of the users currently running a SBC with 2+gb RAM?
Are there further tips and tricks to improve the memory consumption?
Your Environment
The text was updated successfully, but these errors were encountered: