uptime-kuma-api: Memory Leak
It seems like this API has a memory leak.
I have used this python program to test it:
import threading
import time
from uptime_kuma_api import UptimeKumaApi
api = UptimeKumaApi("https://up.obco.pro")
print("Connected")
api.login("Yonggan", "PASSWORD")
print("Login")
def update():
api.get_important_heartbeats()
def uptime_kuma_polling():
while True:
update()
time.sleep(10)
if __name__ == '__main__':
uptime_kuma_thread = threading.Thread(target=uptime_kuma_polling)
uptime_kuma_thread.start()
The output was as expected:
mprof: Sampling memory every 0.1s
running new process
running as a Python program...
Connected
Login
So after the Login i am looping every 10 seconds to get the important heatbeats.
This is just a short example. I recognized it because my Horus flask app that is using this API used 1,5GB memory after some hours.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 38 (14 by maintainers)
Looks very good. Thank you very much for testing. Because of the breaking changes (changed return values of the methods
get_heartbeats
,get_important_heartbeats
,avg_ping
,uptime
,get_heartbeat
andcert_info
) I have to release a new major version. I need a few days to check if there are any other useful breaking changes that should be included in this version.More than 2 days without the OOK
Hi, just started.
Lets watch. I let you know.
@Y0ngg4n @zimbres I think I have fixed the issue (bugfix/memory-leak). Some events were added to a list after they were received, without ever limiting the size of the list. I now handle the events in the same way as uptime kuma does (example).
It would be very helpful if you could test this. But note that I have changed the return values of the methods
get_heartbeats
,get_important_heartbeats
,avg_ping
,uptime
,get_heartbeat
andcert_info
.Uninstall the python module:
And install it again from the bugfix branch:
It’s included in release 1.0.1
@lucasheld
So far, running smoothly
Thank you for reporting this. It is not supposed to be like this. I will fix it soon.
@lucasheld wow 🥳 great! Thank you for your work! I will check it the next days if it fixed the issue and will give you a feedback. 😊
The monitors were ping and http as described by @zimbres. But yes, I will test all this, also in combination with notifications and other elements.
@zimbres thats a good workaround for now! thank you for that!
@lucasheld Give me some time to investigate which monitor is causing this problems.
That would be great!
@zimbres thats way too much.