From 1aed2e7f62dee1ec4c1d5d091af8d650ef82bac2 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Fri, 17 Nov 2023 16:59:12 +0100 Subject: [PATCH] reporting allocation every 300 seconds --- plugin.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugin.py b/plugin.py index e5da94ff1..ed892318d 100644 --- a/plugin.py +++ b/plugin.py @@ -142,6 +142,7 @@ lookupForIEEE, night_shift_jobs, removeDeviceInList) from Modules.traceMemoryAllocation import (check_memory_allocation, dump_trace_malloc, + report_top10_allocation, start_memory_allocation_tracking) from Modules.txPower import set_TxPower from Modules.zigateCommands import (zigate_erase_eeprom, @@ -699,6 +700,7 @@ def onStart(self): def onStop(self): # sourcery skip: class-extract-method Domoticz.Log("onStop()") + report_top10_allocation(self) dump_trace_malloc(self) uninstall_Z4D_to_domoticz_custom_ui() @@ -887,6 +889,9 @@ def processFrame(self, Data): # stop_time = int(time.time() *1000) # Domoticz.Log("### Completion: %s is %s ms" %(Data, ( stop_time - start_time))) + # Release Data memory + # del Data + def zigpy_chk_upd_device(self, ieee, nwkid ): chk_and_update_IEEE_NWKID(self, nwkid, ieee) @@ -984,6 +989,10 @@ def onHeartbeat(self): self.HeartbeatCount += 1 check_memory_allocation(self, "onHeartbeat %s" %self.internalHB) + + if (self.internalHB % 300) == 0: + report_top10_allocation(self) + # Quiet a bad hack. In order to get the needs for ZigateRestart # from WebServer if "startZigateNeeded" in self.ControllerData and self.ControllerData["startZigateNeeded"]: @@ -996,12 +1005,8 @@ def onHeartbeat(self): return if self.transport != "None": - self.log.logging( - "Plugin", - "Debug", - "onHeartbeat - busy = %s, Health: %s, startZigateNeeded: %s/%s, InitPhase1: %s InitPhase2: %s, InitPhase3: %s PDM_LOCK: %s ErasePDMinProgress: %s ErasePDMDone: %s" - % ( self.busy, self.PluginHealth, self.startZigateNeeded, self.HeartbeatCount, self.InitPhase1, self.InitPhase2, self.InitPhase3, self.ControllerLink.pdm_lock_status(), self.ErasePDMinProgress, self.ErasePDMDone, ), - ) + self.log.logging( "Plugin", "Debug", "onHeartbeat - busy = %s, Health: %s, startZigateNeeded: %s/%s, InitPhase1: %s InitPhase2: %s, InitPhase3: %s PDM_LOCK: %s ErasePDMinProgress: %s ErasePDMDone: %s" % ( + self.busy, self.PluginHealth, self.startZigateNeeded, self.HeartbeatCount, self.InitPhase1, self.InitPhase2, self.InitPhase3, self.ControllerLink.pdm_lock_status(), self.ErasePDMinProgress, self.ErasePDMDone, ), ) if not _post_readiness_startup_completed( self ): return