Skip to content

Commit

Permalink
Merge pull request #2413 from ayasa520/fix-scanp
Browse files Browse the repository at this point in the history
fix: Memory leak caused by scanp command due to handler's reference of plugin instance
  • Loading branch information
Saboteur7 authored Dec 13, 2024
2 parents 857ce1d + 2a351ca commit 9f7e2e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def activate_plugins(self): # 生成新开启的插件实例
self.disable_plugin(name)
failed_plugins.append(name)
continue
if name in self.instances:
self.instances[name].handlers.clear()
self.instances[name] = instance
for event in instance.handlers:
if event not in self.listening_plugins:
Expand All @@ -165,6 +167,8 @@ def reload_plugin(self, name: str):
for event in self.listening_plugins:
if name in self.listening_plugins[event]:
self.listening_plugins[event].remove(name)
if name in self.instances:
self.instances[name].handlers.clear()
del self.instances[name]
self.activate_plugins()
return True
Expand Down

0 comments on commit 9f7e2e1

Please sign in to comment.