Here is a quick update summarizing the changes I have made over the past few days. I am convinced I have removed 99% of the memory leaks. The memory on my Raspberry Pi stayed pretty stable yesterday.
The summary of what has changed is this:
import gcwas added to garagemonitor.py (the Python Garbage Collector).
gc.collect()was added to the end of my main loop (so its runs on each cycle and tries to free any orphaned variables/objects).
keep_garage_monitor_active.shbash script was created to researt the garagemonitor service when the script is no longer in the process list (for some reason it has terminated a couple of times on me, I am not sure why).
- The Status web page no longer reload the entire page every 10 seconds. Instead, it now uses AJAX to query the Web Service every 5 seconds. It now only reloads the page when the status has actually changed. This saves workload and bandwidth for the server, and moves more of the work to the client’s browser.
- The Status web page background grows bright then returns to the normal color to indicate when the status has been updated.
I may even rework the status webpage all together again so it never reloads the entire page again. I am looking at the jQuery Mobile framework right now.
As always a stable version of my code is avilable at Github.