Strategy for safely reducing memory usage of OH3 on RP3B+

Hello,

What would be the minimum amount of java workers/tasks/childs to launch at boot to save system memory? It will be a very lean system, few things, several items…

Thank you,

Rom Pereira

I am so out of the JVM scene… Maybe it is caching the memory up to 75% or so to reserve memory for the workers? Because it does not seem to be using like 700 MB of RAM.

I was checking some configuration files and find the following at /etc/default/openhab:

EXTRA_JAVA_OPTS="-Xms192m -Xmx320m"

-Xms means the Starting amount of memory reserved for Heap
-Xmx in the same way, means Maximum amount of memory reserved for Heap.

Java is quite funny about memory usage, if I may remember correctly (mind you, the last time I developed with it was 2004), had:

  • stack - where your JVM stacks and registers are at
  • permanent - where your classes are at
  • HEAP - the memory for your java apps to actually run in

Both XMS and XMX are HEAP configuration parameters, being 192 MB the starting point to 320 MB of maximum per instance. In this case I do believe that probably it is running two instances of the JVM Server or whatever the young folks from the Apache Fundation are cooking up over there those days.

It’s a single JVM.
Those values are optimized for a 1GB ARM server (Raspi 2/3) so feel free to mess with them if you have too much spare time but there’s no need to.

I see, but where this optimization is configured? I mean, I guess I was in the right file…

yes you were

You may be getting mixed up with Linux VS Java using the memory. To be clear, how are you looking at the “used” ram? are you for example typing in …

free -h
htop

or another method?

Linux by default will chew your ram up for CACHE and not release it unless you need the ram, so it can be confusing looking at some of the stats if your not used to it.

If you really want to see the ‘heap’ you can go into the openHAB console (see docs on how to reach this) and then type in shell:info but that will go up and down like a yoyo and to understand it you need to read about how garbage collection works in Java. Which once again it only frees up space when it is actually needed so it can be confusing yet again…

Or just ignore it all and enjoy using it if you don’t have any issues. If you are having issues, you will have a much nicer time in the forum if you include that information.