Memory usage OpenHab 3.1 (Raspberry Pi 3)

Hi all,

a short question, how is your memory behaviour? Mine is very very tight with 1 GB.
Are there some ideas how to Optimzie the performance on a Raspi or figure out how many ram is consumed?

  • Platform information:
    • Hardware: Raspberry Pi 3 B
    • Ram: 1GB
    • openHAB version: 3.1

See here my top:

top - 15:44:04 up  3:31,  1 user,  load average: 1.24, 1.19, 0.75
Tasks: 172 total,   2 running, 170 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.4 us,  4.6 sy,  0.0 ni, 81.9 id, 11.7 wa,  0.0 hi,  0.3 si,  0.0 st
MiB Mem :    909.9 total,     25.5 free,    773.5 used,    110.9 buff/cache
MiB Swap:    100.0 total,      0.0 free,    100.0 used.     76.9 avail Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   3150 openhab   20   0 4472396 534396   1024 S   2.4  57.4  22:04.66 java
   1050 pi        20   0 1070004  50544   2772 S   0.0   5.4   1:24.95 influxd
  33374 root      20   0 1272452  46092  30072 S   7.6   4.9   0:00.48 docker
    599 root      20   0 1881828  33676   4612 S   0.6   3.6   1:05.99 dockerd
   1057 root      20   0  274424  16188      0 S   0.3   1.7   0:10.06 node
    496 root      20   0 1554968  14424   1832 S   0.2   1.5   1:02.44 containerd
   1839 www-data  20   0  196420   6880   2804 S   0.0   0.7   0:00.27 php-cgi
   1840 www-data  20   0  196288   6864   2832 S   0.0   0.7   0:00.14 php-cgi
   1838 www-data  20   0  196288   6804   2840 S   0.0   0.7   0:00.09 php-cgi
   1841 www-data  20   0  196288   6772   2844 S   0.0   0.7   0:00.20 php-cgi

Here my Shell Info:

Karaf
  Karaf version               4.3.2
  Karaf home                  /openhab/runtime
  Karaf base                  /openhab/userdata
  OSGi Framework              org.eclipse.osgi-3.16.200.v20210226-1447

JVM
  Java Virtual Machine        OpenJDK 64-Bit Server VM version 11.0.11+9-LTS
  Version                     11.0.11
  Vendor                      Azul Systems, Inc.
  Pid                         25
  Uptime                      3 hours 2 minutes
  Process CPU time            20 minutes
  Process CPU load            0.00
  System CPU load             0.50
  Open file descriptors       375
  Max file descriptors        1,048,576
  Total compile time          9 minutes
Threads
  Live threads                276
  Daemon threads              151
  Peak                        315
  Total started               11277
Memory
  Current heap size           132,029 kbytes
  Maximum heap size           225,728 kbytes
  Committed heap size         194,344 kbytes
  Pending objects             0
  Garbage collector           Name = 'Copy', Collections = 317, Time = 12.389 seconds
  Garbage collector           Name = 'MarkSweepCompact', Collections = 8, Time = 4.702 seconds
Classes
  Current classes loaded      26,029
  Total classes loaded        26,099
  Total classes unloaded      70
Operating system
  Name                        Linux version 5.10.63-v8+
  Architecture                aarch64
  Processors                  4

Here my memory statistics from OH here (the “down pointing” are crashes and restarts) :slight_smile:

BR
Franz

Running openHAB with a bunch of other stuff on an RPi 3, particularly running a bunch of other stuff in Docker is not recommended. openHAB needs a lot of memory (relatively). A typical installation will want 450-600 MB of RAM. And you seem to be well within that range. But you are also running a lot of other high RAM processes on this same machine which is why you are running out of memory.

You should either:

  1. Move the Docker stuff, node (assuming that isn’t Frontail) and PHP stuff to another RPi or
  2. Move everything to an RPi 4 with at least 4 GM RAM.

A bad idea, it uses a lot more mem than the 32 bit version does.

Use openHABian, it’s memory optimized. I myself run my home on a RPi3, too.

Thanks @rlkoshak
and especially to @mstormi,

downgrading to arm32v7 did the job!

top - 09:01:03 up 38 min,  1 user,  load average: 0.07, 0.89, 1.45
Tasks: 162 total,   1 running, 161 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.9 us,  2.4 sy,  0.0 ni, 92.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    922.8 total,     91.7 free,    526.1 used,    305.0 buff/cache
MiB Swap:    100.0 total,     97.2 free,      2.8 used.    346.7 avail Mem

Are there any other hacks to reduce the memory footprint of Openhab?

BR
/Franz

Hi, I am in the same situation since I upgraded my OH version to v.3x. Can you pls share with us the steps you downgraded to arm32v7?

Thank you
AgOH

Hi AgOH,

it was quite simple to me because I used docker.
Just saved the /opt/ directory, downloaded the arm32v7, installed docker, copied the /opt/ directory back and then docker-compose up -d.

Alternative: backup this folders, put it back and start
- openhab/conf"
- openhab/addons"
- /openhab/userdata"
- openhab/userdata/persistence/rrd4j"

Alternative2: run the openhab backup full (bold is without docker) save the file and do a restore afterwards.

docker exec -i openhab3_openhab_1 /openhab/runtime/bin/backup --full $backparthinImage/openhab-backup-full0.zip