Mike Loose
05/03/2024, 11:13 PMMike Loose
05/04/2024, 8:33 PMdef log_memory_usage(mem_dict, event):
# Get the memory usage information
memory_info = psutil.virtual_memory()
# Convert memory info from bytes to gigabytes
total_gb = memory_info.total / (1024**3)
used_gb = memory_info.used / (1024**3)
available_gb = memory_info.available / (1024**3)
# Check if mem_dict is empty
if not mem_dict:
next_key = 0
else:
next_key = max(mem_dict.keys()) + 1
mem_dict[next_key] = (event, f"Used: {used_gb:.2f} | Tot: {total_gb:.2f} | Avail: {available_gb:.2f}")
return mem_dict
Availability memory appears to be the correct one to track, this is different than what the VM memory chart in Proxmox seems to be reporting. I can see now that I have much less memory leak as a result of prefect runs. It seems like there is about 250MB that gets consumed after the first prefect run after a reboot. After that it actually seems to stay pretty steady.
Monitoring memory with htop from Linux CLI suggests about 10MB memory leak per run, but who knows maybe that is just from some other unrelated process going on.
For the time being it seems to be just fine. Maybe one day I'll need to dig deeper, but good enough for now.Matthew Bell
05/05/2024, 1:23 AM