Java runs amok weekly

Hi,
I’m on openhab 2.5.9 on MacMini and the folder of stuff just sits on my desktop. I run it as the normal Terminal user. Every week or so the fan on my MacMini ramps up and MacFans shows the CPU core temp shooting up and I just know that Java has got out of control yet again! The ‘Activity monitor’ utility usually shows 150-200+% CPU usage…totally hogging the system! I’m frustrated with this instability.
My openhab system is very modest in size. 28 ‘things’, some of which are ‘services’ rather than hardware, spawning about 50 ‘items’, 6 bindings and 11 ‘rules’.
The only cure is to logout openhab in the terminal, thus killing Java and restart openhab again.
Has anyone any idea why Java is doing this??? Hope someone has suggestions.
regards and thanks,
Denis

Any Hint what Java version you are running ?

Hello Hans, thanks for your reply. Ver 8 since that’s what’s recommended for openhab 2.
Below is a copy from my Terminal output when I do a ‘java -version’ command so you have the fuller details:
" Burnsides-Mac-mini:~ burnsidecottage$ java -version
openjdk version “1.8.0_252”
OpenJDK Runtime Environment (Zulu 8.46.0.19-CA-macosx) (build 1.8.0_252-b14)
OpenJDK 64-Bit Server VM (Zulu 8.46.0.19-CA-macosx) (build 25.252-b14, mixed mode)"
thanks,
Denis

It could be that the garbage collector is running all the time as you are running out of heap space. When this happens can you post the output of shell:info command in the console?

I’d believe in garbage collection, too.
But as just very few people use a Mac, I think you won’t get many useful answers.
(and a Mac is a weird proposition to run 24/7. why don’t you change to a RPi ?)
Check out https://dzone.com/articles/how-to-tune-garbage-collection-in-java and try some of the proposals there.

Hello Skinah & Markus,
Thanks for your replies. We are getting into specialised areas that I know little about… it is a fact though that the Mac OS itself has its own ‘garbage collection’ built in so that’s not the problem. This looks to be a Java ‘garbage collection’ issue and I’ve no idea what to do about it… also folks, could we not have this ‘Mac OS’ bashing thing starting up… :roll_eyes: there’s NOTHING ‘weird’ about using an old MacMini as the basis of : my IP security cam system + my Plex Media server + my Openhab system… yes that’s what I currently do and it has plenty of memory! Macs, built on UNIX, are inherently more stable and longer lasting than pee-cees. I appreciate that lots of ye like the R-Pi for the elegance of it but I haven’t played with them and it makes sense for me to make use of older Mac’s I have around :slightly_smiling_face:
Anyway, it seems to me that Openhab , built around Java is the culprit here and we’re all stumped…
Denis

addendum: the article below says NOT to try tune but to improve the program code… it’s very technical (for me) but it seems to say Openhab is the problem rather than fiddling with Java…?
https://dzone.com/articles/the-most-reliable-way-to-reduce-gc-pauses-is-not-b

Like it or not, a Mac is an unusual host environment for openHAB. There won’t be much exposure or niche skills here.

Have you gone at this from the other end? You’ve looked in your openhab.log and events.log for activity preceding the problem? You’ve looked for a pattern in “every week or so” - is it similar times of day, what times of day has it not happened, etc.?

A little thin-skinned, even for an Apple follower… but you completely misunderstood me. That’s not bashing, and it’s not about MacOS. I would have said the same if you had said you use a PC.
Points are 1) it’s an exotic device to run openHAB, way off the mainstream (RPi) and this is why there’s only very few people (if any at all) to have the experience it takes to help you and 2) your server ain’t dedicated to openHAB, that is all the rest you do on the machine has an impact on openHAB.
If it was a RPi, we would know the proper Java settings it takes and could tell you. Or you wouldn’t have run into this in the first place because this has been ironed out long ago (the openHABian Pi image for example sets these Java params by default).

Hi Ross,
I can try look at the logs but the problem is not knowing exactly when Java goes berserk… it could go unnoticed for hours or days depending on when I’m working on the MacMini with the other applications. It’s a good point so I’ll follow up.
Denis

Hi Markus,
Apologies…it’s just I’ve worked in a predominately PC environment in my academic work place (I can use them btw) and have always been the ‘square peg’ so apologies for being a little touchy about it… :neutral_face: I really do appreciate you taking the time to help, so thank you.
Its a pity that Openhab seems so particular that it wants its very own machine and needs this fiddling with Java parameters. I was hoping for a more stable self-regulating program when I migrated from the Vera Plus (MiOS) and put considerable effort into learning syntax and rules etc etc for Openhab. It’s disappointing. So looks like fiddling with Java or migrating again to a different Smart home system… :frowning_face:
Hoping there’s a ‘square peg’ out there who can help… thanks again to those who’ve replied so far.
Denis

That’s not openHAB to “want” it but a valueable advice from professional system architects and experienced home automation users how to deploy your HA system best. There’s reasons why this is even part of the introductory(!) paragraph of the openHAB docs.
And it “needs” fiddling on exotic platforms only so that’s merely effect of your decision to use such a platform.

Better give up on the idea that is has to be a Mac to run on.
Drop your dogma, use the right tool for the right job and you’re set.
Even give up on openHAB just for that ? Why waste your investment ?
Learning another HA system is way more difficult and time consuming.

Okay, it would seem smart to find out. As someone hosting OH on Windows, I have no idea what system monitoring resources are available on your Mac - presumably some graphing?

I doubt this is a problem with garbage collection or core. Otherwise this should be much more common. So to find out your problem you need to look at what is specific for your installation. And that are bindings and rules. So either a binding goes out-of-control or you have written a rules that kills your system.

If it’s a memory problem you can simply monitor the memory usage and if it increases over time this is an indication of a memory leaking problem, and could cause openHAB to reach the configured max usage, which can cause problems.

So to see what the other cause might be, look in the log at what bindings where running just prior to when the system started to fail. To see if a rule is the problem, add logging to the rule to see the rule is doing something when the system starts to fail.

Another option can be to disable bindings and see how the system behaves. But since your problem occurs irregularly this might take some time.
Also search the forum on your bindings to see if other people have reported problems.

Hi Markus,
I have read the introductory paragraph on Openhab and it welcomes ALL Platforms and MOST hardware as being suitable for running on!!! …then there’s a gentle recommendation to use a dedicated system ‘in the long run’… I’m afraid you’re being self contradictory here… either it’s suitable or not for all those platforms or it isn’t… the architects should stop offering it on all the other platforms if, as you say, it needs a dedicated system and preferably one that should be a RPi… I feel that that dogma is being foisted upon me… :roll_eyes:

It does not need to be a Pi, my openHAB runs without any issues on a Intel NUC with Ubuntu Server 18.04 …

Hi Hilbrand,
Thank you for your reply. I’m inclined to agree with you that this isn’t a Java memory management problem but something with a Binding or a rule as you suggest.
I’ll follow your recommendations, particularly to add logs to the rules.
As I said in my original post, my system seems modest in size and scale, running on an exotic platform :wink: and it seems incredulous it should keel over regularly like this,
Thanks again,
Denis

@Kai as you are running openHAB on a Mac, any hints from your side ?

Hi Hans,
Well that’s good news, I’m encouraged to stay with my MacMini and try persist and get to the bottom of all this. As Markus said, it would be a pity to throw away my time investment on Openhab but it can be very challenging to learn.
thanks,
Denis

Hi Hans,

Yes you’ll see in my original post I’m on a MacMini. In case the threads got lost, here’s a copy:
"I’m on openhab 2.5.9 on MacMini and the folder of stuff just sits on my desktop. I run it as the normal Terminal user. Every week or so the fan on my MacMini ramps up and MacFans shows the CPU core temp shooting up and I just know that Java has got out of control yet again! The ‘Activity monitor’ utility usually shows 150-200+% CPU usage…totally hogging the system! I’m frustrated with this instability.
My openhab system is very modest in size. 28 ‘things’, some of which are ‘services’ rather than hardware, spawning about 50 ‘items’, 6 bindings and 11 ‘rules’.
The only cure is to logout openhab in the terminal, thus killing Java and restart openhab again.
Has anyone any idea why Java is doing this??? Hope someone has suggestions.
regards and thanks,
Denis

No there’s no contradiction. Don’t mix the two statements!

That means: use a dedicated system when in production (which I’d say you are in).
It doesn’t say RPi. It just says ‘don’t run anything else on your HA server’ and implies to ‘run headless’.
A NUC is fine, too, Windows OR Linux. A small Mac is fine, too. Just don’t use it for anything other than openHAB.
If you choose to nonetheless use a shared system, be prepared this will create risks and likely will cause issues.

HW and OS is a separate question … when you start with OH - which is what the paragraph is about -, it’s easier to (re)use the OS you are used to so you don’t have to fight with issues of an to you unknown OS and can focus on getting OH to work, hence the recommendation. This is mostly directed at Windows users we want to protect from UN*X hell but it’s true for Apple users as well.
Now that doesn’t mean that any HW and OS that OH runs on (which is essentially EVERYTHING, there’s even Java for mainframes …) is equally well suited.
There’s lengthy threads on the forum to discuss this that I don’t want to repeat here.
The IMHO best advice - and it’s just advice you don’t have to take - is to use what most others use unless you’re an expert in the HW/OS combo you want to use and confident that you can solve any problems to rise yourself. This is because you’ll have a largish audience in the community that can help you if you encounter problems, and more problems will have been solved already by others to have hit them earlier by the time you start so you don’t get hit again by these.
Absolutely fine to stick with your Mac here, too … but worth reconsidering given you have issues you cannot solve. To nonetheless keep sticking with it even to an extent that you consider giving up on OH(!) rather than to change platform is what I mean by acting dogmatic.