Activate HeapDumpOnOutOfMemoryError on macOS

Hi Everybody,

unfortunately my openhab installation is not running fine any longer since a Java+OH2 update. After a while I receive OutOfMemory error messages and openhab stopped working properly.

openhab> Exception in thread "OH-common-262" java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:717)
	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
	at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1018)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Exception in thread "upnp-async-686" java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:717)
	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
	at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1018)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Exception in thread "upnp-async-683" java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:717)
	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
	at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1018)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Exception in thread "OH-common-275" java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:717)
	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
	at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1018)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)

Now I checked within this forum what I can do to detect the module which introduces this memory leak. I figured out that OH2 can create a Heapdump when this out of memory error appears.

As I’m not a Java developer AND I’m using a mac I have no clear understanding where I have to place this line:

EXTRA_JAVA_OPTS="-XX:+HeapDumpOnOutOfMemoryError"

Can someone point me to the proper file where I can place this line? :slight_smile:

Thanks a lot!

Cheers
Dennis

On my system ( not MAC ) it’s in the file /etc/default/openhab2.
Do you use amazonechocontrol ? There is a fix for this problem which was provided about two weeks ago.

Hi Wolfgang,

thanks for your reply! I do not have a file located at /etc/default/openhab2 :-/
Any other idea how to enable HeapDumpOnOutOfMemoryError?

The information about the amazonechocontrol plugin is really interesting. I had an old version active:

openhab> bundle:list | grep Ama
203 │ Active │  80 │ 2.4.0.201811041600      │ Amazon Echo Control Binding

I updated this to the new 2.5.6 version right now - this should fix the issue as mentioned here:

So maybe this already will solve my issue - lets see

Cheers
Dennis

in case you do not have that file investigate how openhab is started up.
I think there should be a start.sh file.
That file checks if /etc/default/openhab2 or if /etc/profile.d/openhab2.sh exists and sources the first one that is found.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.