IpCamera: New IP Camera Binding

@Pedals2Paddles

For anyone that gets OOME (out of memory errors) with the java heap space, then this is how I solved it to allow me to drop the refresh down to 1000ms. I have had my two cameras running for >24 hours without issues. I suspect this has to do with javas garbage collection not running often enough to deal with the large amounts of data passing through the image item if you are running your system close to the max allocated heap size.

In the openhab console run this command (optional just for your info)

shell:info

It gives you output like this…

Karaf
  Karaf version               4.1.5
  Karaf home                  /usr/share/openhab2/runtime
  Karaf base                  /var/lib/openhab2
  OSGi Framework              org.eclipse.osgi-3.12.50.v20170928-1321

JVM
  Java Virtual Machine        OpenJDK Client VM version 25.152-b76
  Version                     1.8.0_152
  Vendor                      Azul Systems, Inc.
  Pid                         418
  Uptime                      13 hours 15 minutes
  Total compile time          12 minutes
Threads
  Live threads                175
  Daemon threads              71
  Peak                        199
  Total started               6482
Memory
  Current heap size           183,100 kbytes
  Maximum heap size           243,520 kbytes
  Committed heap size         238,552 kbytes
  Pending objects             0
  Garbage collector           Name = 'Copy', Collections = 8778, Time = 4 minutes
  Garbage collector           Name = 'MarkSweepCompact', Collections = 437, Time = 7 minutes
Classes
  Current classes loaded      20,333
  Total classes loaded        20,509
  Total classes unloaded      176
Operating system
  Name                        Linux version 4.14.52-v7+
  Architecture                arm
  Processors                  4

Run this in linux to open the file for editing after typing in logout to exit the console. (required: this is changing the heap size)

sudo nano /etc/default/openhab2

Change the already existing line to have this if it is empty. The -Xmx512m gives the heaps more space to grow up to a max of 512mb. (required: this is changing the heap size)

EXTRA_JAVA_OPTS="-XX:+HeapDumpOnOutOfMemoryError -Xmx512m"

Save and exit using the commands listed at the bottom of the screen, then…

sudo reboot

Lastly you can check the ram usage with this command… (optional)

free -h

example output after doing the above and a reboot on a pi2 is

              total        used        free      shared  buff/cache   available
Mem:           976M        373M        374M        9.7M        228M        545M
Swap:           99M          0B         99M

1 Like