The better solution is to monitor the amount of free system memory and reboot when it gets too low. I use the /proc file system to access the system memory status, the awk command to pull out the value that I need, and a bash script to tie it all together.
lowmemreboot.sh
#!/bin/bash
declare -i fmem
while [ true ]
do
fmem=` awk '/MemFree/ { print $2 }' /proc/meminfo`
if [ "$fmem" -lt "10000" ]
then
echo FREE MEMORY IS LOW----FORCING REBOOT
reboot
exit
fi
sleep 60
done
Note that the command that awk runs is surrounded with single quotes. The entire command is surrounded with back quotes. This causes the output of the command to be saved in the fmem variable.
This script is run from /etc/rc.local the same way that wait-for-gpio-trigger.sh is run. When the free system memory drops below 10K, the system will reboot and all is well again for a while. Now I can just let the picture frame run forever and not worry about it.
I would like to see someone write a real slideshow program that does multiple transition types and supports controls such as pause and reverse. I have too many more interesting projects on my mind, but maybe someone will find the time to do this.
For $8 you could add wifi, and have NTP sync'd time. :-)
ReplyDeleteRegardless, your solution is definitely the better way to solve your problem.
This particular frame hangs on the wall in my office at work. Corp policy will not allow me to attach a "non-approved" device to the network.
DeleteBesides, there isn't really room for anything to plug into the USB port the way that I mounted the hardware. See the pictures in the post about the Jumbo Digital Picture Frame.
I am building a much nicer looking frame for home. (The wife wants one.) It will have an all wooden frame - none of the plastic from the original monitor will be used.
DeleteThat one will have WiFi just to make it easier to use. The picture directory will be shared using Samba, so I can just drag and drop pix.
You could just use monit so you don't have to run your bash script. Monit would allow you to restart your server if cpu is too high, not enough memory, etc.
ReplyDeletecheck system
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
Something like this, or exec 'reboot' instead of alert. Found your blog searching Google for connecting my new raspberry with an alarm system, to start video recording/motion only when turning the alarm on.
Might not be good enough in electronic to actually build the full alarm system (easy, one door and one infra red detector).
Hi Ted
ReplyDeleteAs regards to your memory leak, instead of rebooting the Pi, why not find the source of the problem?
Nice site b.t.w.
The leak is in the Frame Buffer Interface application (fbi) and have no desire to debug it. That can be someone else's problem.
DeleteAnd I came up with a much easier fix that should have been obvious from the beginning. I just run the fbi program in a loop. When it crashes, the memory is freed up and then it just runs again. It has been running non-stop for about three weeks now.