What -Xms (and -Xmx) options do you use?

Continuation of this thread : Raspberry Pi 4 released
A side-discussion started between myself. @mstormi and @matt1 which is quite interesting.

This is why I raised the value. I have a number of rules which do calculations on power usage / generation. Seeing as the usage fluctuates a lot (shifts by 1-2Ws every reading / less than 5 seconds) these rules fire often.
I measure power usage, solar generation and a number of circuits in the house. Based on this, these rules were always running and I figured I would increase the cache size.

Was this right or wrong?

Considering I now have a RPi4 with 4GB of RAM is there any better value? Why not just peg them (Xms and Xmx) both at 1GB? Assuming there is nothing else running on the RPi.

Based on what @matt1 says, I am just about right? (But I am interested in hearing @mstormi view as it too makes sense. :slight_smile:

C

Personally i increased both values -Xms to 500m and -Xmx to 1024m

To make the information mor complete. Running a VM on my synology with debian

It’s quite simple:
Start with the defaults and increase gradually if you encounter lags in rules execution. If you do not, stay with your settings.
For openHABian Xms/Xmx defaults are 250/350 which is fine for a 1GB ARM system and on x86 or ARM boxes with more mem probably not more harmful than the defaults.
If you run on 64bit x86 you need more as code and data are usually 4 times larger. But I don’t use x86 so I cannot and won’t recommend anything there.

To increase beyond what’s needed results in more paging. That’s harmful to SD cards. If you don’t run on SD you don’t need to care but even a RPi4 still uses SD so I would.
And it’s very unlikely you have a benefit. As you can imagine I’ve got a large number of rules and they all execute without lagging so they fit into those Xms=250MB I use.

1 Like

Because there are no single optimal settings, they depend on many more stuff like HW, programs you run beyond OH and more. It’s no beginner topic.
Beginners should use openHABian so for a RPI2/3 they get those values anyway.

There is some useful info written here which since most people use Zulu some of what is written may not be accurate for zulu, but the discussion around xms and xmx is fine.

https://docs.oracle.com/cd/E21764_01/web.1111/e13814/jvm_tuning.htm#PERFM159

  1. Type free -h in the terminal and check how much swap is used. If you are not using swap then your max heap space is fine if it also passes the test in point 2. Increasing the heap too much takes away ram from non Java apps and also cache. Cache is great as it may mean a SD card read is not needed as the file is already in ram. It also impacts the GC if you set it too big AND too small.

  2. Look at what your current heap size grows and shrinks to, you only need to know a rough min and max value. If the min value is <15% of your xmx value, then you may want to consider dropping xmx down lower. This is due to GC reasons and your system can probably make good use of the ram for cache.

  3. Make both xmx and xms the same value so the system does not keep resizing it which you will see this in the ‘committed heap size’ value if it keeps changing. It makes things simple to keep them the same, but you probably won’t notice either way.

If you press the up arrow on your keyboard it will re show the last command you used, so you can watch the values this way, or there are more advanced tools for watching the contents of the heap in real time which I often do to look for memory leaks. Everything that runs in java uses the heap (bindings, rules, the openhab backend and more) and everything outside of Java uses the ram that is left over.

I totally agree and when you have 4gb of ram it is FAR easier to find a value that works compared to a juggling act on a 1gb limited setup.

Sounds like that will be fine, but it would be interesting to know what range your heap size shrinks and grows between instead of a static known number from your pic. There is no perfect number, it is just you need to make sure you don’t run out of heap space and also don’t set it excessively high.

Again: NO. This is about right for the Xms value but not the Xmx one. Xmx high doesn’t do harm.