-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handler 对 插件实例的引用导致 scanp 命令引起内存泄漏 #2412
Comments
…o plugin instance. close zhayujie#2412
Thanks for the PR, it has been merged. |
大佬,同理在Event.ON_RECEIVE_MESSAGE也存在这种情况,只要每scanp一次,这个就会重复出现多一次,可否也帮忙调整下?具体怎么解决我就真的小白搞不懂了不好意思
|
…o plugin instance. close zhayujie#2412
…o plugin instance. close zhayujie#2412
前置确认
操作系统类型?
Linux
运行的python版本是?
other
使用的chatgpt-on-wechat版本是?
Latest Release
运行的
channel
类型是?wx(个人微信, itchat)
复现步骤 🕹
开启管理员插件以及任意其他插件, 执行
#scanp
命令问题描述 😯
期待行为是原本插件的实例被 gc 回收, 但是由于插件中 handler 对插件 self 的引用, 导致之前的插件实例永远不会被销毁.
执行
gc.get_referrers(self.instances[name])
结果如下图解决方法有两种:
在
self.instances[name] = instance
之前清空self.instances[name].handlers
, 以消除对插件实例的引用.使用 weakref
在插件中添加handler时
在 emit_event 中
显然方法 1 改动更少, 方法 2 需要更改现存的所有插件. 我会就方法 1 提一个 PR
终端日志 📒
无需日志
The text was updated successfully, but these errors were encountered: