pypowerwall - memory usage #25
-
I use Grafana and InfluxDB to monitor my Pi4's vital stats. Recently I noticed that my memory used was steadily climbing. When I checked the Task Manager in the Pi4 GUI I found that Python3 was using a lot of memory in the "VM-Size" column. After rebooting the Pi the total memory use dropped down a lot. I've been watching the memory usage since my last reboot about 6 days ago. While pypowerwall isn't the only thing using more memory, restarting my pypowerwall container immediately dropped the total memory usage by about 11%. The memory use by Python3 dropped from over 400MB to < 20MB. Based on the numbers I saw before the reboot, I expect that if I had let it go longer, the Python3 memory utilization would have just continued to climb. Is this normal or could there be a memory leak in pypowerwall or Python3? This image shows the last 7 days. Towards the left you can see the before/after reboot. At the very right edge you can see the restart of the pypowerwall docker container. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @youzer-name ! Thanks for this observation...good find! It seems very compelling that there is a leak. It should grow as it buffers API calls but that should level off and not continue to grow as your graph shows. The pypowerwall proxy uses ThreadingHTTPServer. I did some quick research and believe there are conditions with python 3.7+ with ThreadingHTTPServer that can cause this memory leak. I have put in a recommended fix and I'm running some tests before releasing. Can you help by confirming the version of python as well as pypowerwall (see http://localhost:8675/version)? I'm going to open an issue in https://github.com/jasonacox/pypowerwall for the proxy. |
Beta Was this translation helpful? Give feedback.
Hi @youzer-name ! Thanks for this observation...good find!
It seems very compelling that there is a leak. It should grow as it buffers API calls but that should level off and not continue to grow as your graph shows. The pypowerwall proxy uses ThreadingHTTPServer. I did some quick research and believe there are conditions with python 3.7+ with ThreadingHTTPServer that can cause this memory leak. I have put in a recommended fix and I'm running some tests before releasing.
Can you help by confirming the version of python as well as pypowerwall (see http://localhost:8675/version)?
I'm going to open an issue in https://github.com/jasonacox/pypowerwall for the proxy.