Skip to content

Commit

Permalink
reporting allocation every 300 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Nov 17, 2023
1 parent c64b341 commit 1aed2e7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"]:
Expand All @@ -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
Expand Down

0 comments on commit 1aed2e7

Please sign in to comment.