sfguy
Posts: 6
Joined: Mon Apr 10, 2017 2:14 pm

Pi B+ freezes after some time when running program

Tue Apr 25, 2017 4:01 pm

Good morning!

I wanted to post a more general question to this forum as I got stuck with my Pi B+ (I consider myself as a beginner and the answer might be easy):

I am running a little code that measures the distance between an ultrasound module and an object (with hardware attached). Measurements occur every second, which is needed. The computer functions very well for some time (randomly, but in the ballpark of hours) but then all of a sudden, the program freezes. Only that particular code in that particular window is not responsive anymore. But I still can exit that problem via <CTRL>+C and restart that code. I also can still manage programs in other windows or edit code etc. while that program got stuck.

So - I was wondering if there is any buffer that gets filled up over time and which I would have to empty to avoid this problem.. ? If so, can I insert such a command in the code instead of restarting the Pi every day?

Sorry if this question sound stupid.
I changed distance reading to 1 min to stretch the time, but I really need that 1 sec interval.

Thanks in advance!

HD

pi_everalm
Posts: 33
Joined: Thu Apr 20, 2017 11:44 am

Re: Pi B+ freezes after some time when running program

Wed Apr 26, 2017 6:58 am

The issue may be due to logging, code issues, timing or AN Other reason, whilst you debug, a quick and dirty workaround would be to set up a cron job to run a script say every couple of hours that stops and restarts the code.

Not a fix but a workaround that should keep you up and running whilst you get to the bottom of the issue.

sfguy
Posts: 6
Joined: Mon Apr 10, 2017 2:14 pm

Re: Pi B+ freezes after some time when running program

Wed Apr 26, 2017 9:36 am

Hello pi_everalm,
Thanks for your reply. In this case, I surely have to do a deep debug if there is no obvious reason.
Great idea with a script run in parallel. Is there a code available somewhere (I do not know how to terminate and restart programs from another program).
Cheers,
HD

User avatar
RaTTuS
Posts: 10531
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Pi B+ freezes after some time when running program

Wed Apr 26, 2017 9:45 am

run top - is the memory use growing all the time ? if so you have a memory leak ... fix your code...

or post you code and let someone abuse it to be better
see
git
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

sfguy
Posts: 6
Joined: Mon Apr 10, 2017 2:14 pm

Re: Pi B+ freezes after some time when running program

Wed Apr 26, 2017 12:56 pm

RaTTuS,

Thanks for your comment.
All memory I can read with du -hs or free -h does almost not change from start to freeze after a few hours.

Cheers,
HD

Return to “General discussion”