hass-agent / HASS.Agent

Unofficial development project for the HASS.Agent platform.
https://hass-agent.io
MIT License
227 stars 7 forks source link

Bug: Memory Leak (audio library) #64

Open sreknob opened 4 months ago

sreknob commented 4 months ago

Describe the bug Things on my PC were feeling sluggish, fire up task manager and yikes - hass.agent using 3.5GB memory and 10% CPU. Yikes!

image

To Reproduce Uncertain

Expected behavior Reasonable resource usage 😄

Screenshots

Misc info (please complete the following information):

Please check what's applicable (multiple answers possible):

Additional context I took a memory dump of the process to share privately, if desired. Agent unable to restart itself, needed to be force killed.

Logs Attached, in all their glory. [2024-03-11] HASS.Agent_20240312.log [2024-03-11] HASS.Agent_20240311.log [2024-03-09] HASS.Agent_20240311.log [2024-03-09] HASS.Agent_20240310.log [2024-03-09] HASS.Agent_20240309.log [2024-03-08] HASS.Agent_20240309.log [2024-03-08] HASS.Agent_20240308.log [2024-03-07] HASS.Agent_20240308.log [2024-03-08] HASS.Agent_restart_20240308.log [2024-03-08][E] HASS.Agent_servicestop_20240308.log [2024-03-08][E] HASS.Agent_servicereinstall_20240308.log [2024-03-07] HASS.Agent_20240307.log [2024-03-07] HASS.Agent_restart_20240307.log [2024-03-07][E] HASS.Agent_compatmigrate_20240307.log [2024-03-20] HASS.Agent_restart_20240320.log [2024-03-13] HASS.Agent_20240320.log [2024-03-13] HASS.Agent_20240318.log [2024-03-13] HASS.Agent_20240313.log [2024-03-11] HASS.Agent_20240313.log

amadeo-alex commented 3 months ago

Note for the reference purposes: some of the discussion/investigation is going on the discord - all major discoveries will be posted here.

amadeo-alex commented 3 months ago

All leads are tracing back to audio sensor/commands - more information will follow.

amadeo-alex commented 3 months ago

As per discord conversation, test build with AudioSwitcher instead of CoreAudio library - https://github.com/amadeo-alex/HASS.Agent/releases/tag/2.0.1-alpha-audioleakfix Another test build will be created according to advice from CoreAudio author to try to keep the usage for CoreAudio for audio sensors and commands - https://github.com/morphx666/CoreAudio/issues/27

amadeo-alex commented 2 months ago

Update: CSCore was chosen as a audio information library with DIY solution for activating the devices.