Garage Monitor Memory Leak: Part 1

Update: Garage Monitor Memory Leak, Part 2: Tracing the memory leak.

There is some kind of memory leak happening. I first noticed a problem yesterday when the python script stopped running. The Raspberry Pi was still responding to my SSH requests, and when I ran “ps aux | grep garagemonitor.py”, the script was no longer in memory.

As a troubleshooting step I disabled some of the superflous functions (such as temperature monitoring and startup LED flashing). I have been watching how much memory is free over the past hour or two. The free memory has gone from 299596 to 288784. So it is obvious to me that this is going to run out of memory at some point as well.

Apparently Matt Hawkins from the Raspberry Pi Spy blog is having the same issue. Does anyone have any suggestions? At this point all I can think to do is schedule a reboot every so often.

You can see the source code at: garagemonitor.py

             total       used       free     shared    buffers     cached
Mem:        448996     149780     299216          0      32700      67644
-/+ buffers/cache:      49436     399560

pi@garagemonitor ~ $ free
             total       used       free     shared    buffers     cached
Mem:        448996     150268     298728          0      32712      68052
-/+ buffers/cache:      49504     399492

pi@garagemonitor ~ $ free
             total       used       free     shared    buffers     cached
Mem:        448996     160928     288068          0      33700      71340
-/+ buffers/cache:      55888     393108

pi@garagemonitor ~ $ free
             total       used       free     shared    buffers     cached
Mem:        448996     160212     288784          0      33876      71456
-/+ buffers/cache:      54880     394116

One thought on “Garage Monitor Memory Leak: Part 1”

Leave a Reply