jundl77
Posts: 4
Joined: Thu Jan 29, 2015 9:30 pm

Jar on Raspberry Pi not responding after a long time

Sun Feb 08, 2015 10:57 am

Hello I made a java program with friend that is designed to run 24/7 as a personal assistant on a headless Raspberry Pi. It basically can be used as an alarm and to tell us the weather or news etc. So in order to have it run 24/7 headless, I followed directions from here to have the jar start when the Pi boots up (so it runs as a daemon).

Everything is fine for the first couple hours to a day, but then after an extended period of time (so about a day or more) the jar becomes unresponsive, yet when I SSH into the Pi then it seems like the Pi almost "wakes up" and everything works again.

I read that the Raspberry Pi does not have a sleep mode, so I am confused as to what the cause is, and how to turn it off so that the jar is truly responsive 24/7.

I was wondering if daemon threads go to sleep or if threads generally go to sleep on the Raspberry Pi if they do not do much, because right now our program mostly "sleeps" as it waits for events to occur (like a certain time to hit for the alarm to activate etc.), so it does not do much for most of the time.

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: Jar on Raspberry Pi not responding after a long time

Sun Feb 08, 2015 8:28 pm

Sorry for not being able to help you with what *is* the problem you have, but I can confirm that running a jar (a java program in a jar or even more jars/classpath) is not an issue. I regularly run programs on Pi - including a small clock/temperature display over i2c for days and even months without any issues at all. All worked all the time and nothing slowed down/stopped or exhibited any issues. Also, I run web server (usually built in JDK) and similar - all headless and for long periods of time.

So, problem is probably somewhere else...

jundl77
Posts: 4
Joined: Thu Jan 29, 2015 9:30 pm

Re: Jar on Raspberry Pi not responding after a long time

Mon Feb 09, 2015 9:15 am

Ah ok, do you run all that as a daemon (the weather stuff) or how do you run it on the pi so that is runs all the time?

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: Jar on Raspberry Pi not responding after a long time

Mon Feb 09, 2015 9:26 am

Real question is really what daemon really is?

I run it mostly from command line, but I did run some as a 'daemon', too. Daemon is a process as any other so it shouldn't be an issue.

What you are experiencing points to something completely different: if whole RPi is slowing down - then maybe something else is causing it. When, next time, that happens try to do some investigations: run top, vmstats (or equivalent), etc, to try to determine what is happening to your RPi. Alternatively - try with different SD card - maybe you SD card is wearing out and causing slow down.

If RPi itself is responsive but Java is one that feels 'sluggish', then try increasing JVM's max memory or perm space (depending what is really missing).

As I said - I am really sorry not being able to help you specifically with what is going wrong, but definitively not just Java or RPi.

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Jar on Raspberry Pi not responding after a long time

Mon Feb 09, 2015 9:56 am

Jundl77, which Java VM do you use?
Raspian's standard Oracle Java8 ?

Could you print the "java -version" please?

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: Jar on Raspberry Pi not responding after a long time

Mon Feb 09, 2015 10:03 am

I don't have access to it right now, but over time I used different versions of Oracle's Java7 and/or Java8...

jundl77
Posts: 4
Joined: Thu Jan 29, 2015 9:30 pm

Re: Jar on Raspberry Pi not responding after a long time

Mon Feb 09, 2015 7:24 pm

well I'm running the official java 8 for ARM (1.8.0) right now, and thank you very much guys, I will try that

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: Jar on Raspberry Pi not responding after a long time

Mon Feb 09, 2015 9:15 pm

Got home. Here it is:

Code: Select all

$ java -version
java version "1.8.0_06"
Java(TM) SE Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Client VM (build 25.6-b23, mixed mode)

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Jar on Raspberry Pi not responding after a long time

Tue Feb 10, 2015 7:32 am

clicky wrote:

Code: Select all

$ java -version
java version "1.8.0_06"
Java(TM) SE Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Client VM (build 25.6-b23, mixed mode)
Very well, same here. I downloaded 1.8.0_06 it from here and it runs very well and stable also over longer periods -- I don't need it to run days or weeks like in your case, but for a workday or so without problems.

I would very much be interested in why Jundl77 experiences problems with his Java task. As you (Clicky) said, there's probably something odd going on with his Raspbian installation (i.e. not directly Java related). Of course these indirect bugs or errors are usually hard to find.

jundl77
Posts: 4
Joined: Thu Jan 29, 2015 9:30 pm

Re: Jar on Raspberry Pi not responding after a long time

Tue Feb 10, 2015 10:36 pm

Yes I am wondering too, so I started a new task in a separate thread in an infinite loop that will be logging every minute to a file, I'm curious if it will ever stop, and if so when, I will keep you guys posted.

I will also be trying to the new java version that Fidelius linked and see if that works better

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: Jar on Raspberry Pi not responding after a long time

Wed Feb 11, 2015 8:26 am

Just be careful that SD cards do have limited amount write cycles and I am not sure how well Linux drivers are equipped with logic not to wear out single storage block and scatter writes over the medium.

As I originally said - what if SD card is to be blamed for slowing down and some odd behaviour? Scenario might be (again - more intuition than hard facts) that initial sluggishness after running something for long time is that until kernel load all blocks in cache it takes unusual amount of time due to re-tries on the card and/or kernel driver.

Ideally such operation would go in ram disk and then copied to SD card when it is really necessary, not before. Or running everything from HD.

My examples did almost no logging due to that fact... But SD cards themselves can be really different.

Return to “Java”