Giter Site home page Giter Site logo

貌似有内存泄漏 about wxpy HOT 11 CLOSED

youfou avatar youfou commented on April 28, 2024
貌似有内存泄漏

from wxpy.

Comments (11)

teli5200 avatar teli5200 commented on April 28, 2024

中间登录过后,基本上就没有任何操作了

from wxpy.

youfou avatar youfou commented on April 28, 2024

麻烦确认下环境中安装的 itchat 版本号

import itchat
print(itchat.__version__)

from wxpy.

teli5200 avatar teli5200 commented on April 28, 2024

目前用的最新版本,0.39 ,但是在 centos7 下,每发一条消息,就会增长一点,我是发一个图片和一条文本消息,每次会增长400K 左右内存

from wxpy.

youfou avatar youfou commented on April 28, 2024

你好,我先前发现,与 itchat (wxpy 依赖) 1.3 + 版本搭配使用时,会有比较明显的内存泄露问题,所以目前 wxpy 在 requirement 里指定的 itchat 版本为 itchat 1.2 的最后一个稳定版本。如果使用 pip ,会自动安装匹配的版本。能否知道下你现在环境中的 itchat 版本号?

from wxpy.

teli5200 avatar teli5200 commented on April 28, 2024

我是用的 pip安装的,版本是 1.2.32

from wxpy.

youfou avatar youfou commented on April 28, 2024

是不是每个微信号里都有很多群,且每个群都有很多人?
“内存从开始的 110M,逐渐增长到 230M” 这个过程前后间隔多久?
能不能介绍下这些微信号的规模?


我也帖下我的情况,来自 “wxpy 机器人” 群主机器人

心跳包中的4个字段分别表示 发送时间、在线时间、内存占用、收到和发出的消息数量

刚启动不久,前期内存增长比较快

[now] 09:30:54
[uptime] 0:00:21
[memory] 36.87 MB
[messages] 1

启动 30 分钟后,30 分钟增长了 9 MB,确实很快

[now] 10:01:14
[uptime] 0:30:41
[memory] 45.27 MB
[messages] 53

接下来的20分钟内,新增 26 条消息,但没有内存增长

[now] 10:21:39
[uptime] 0:51:05
[memory] 45.27 MB
[messages] 79

最近一次心跳,又过了8小时,新增 749 条消息,仅增加 9.46 MB 内存

[now] 18:32:20
[uptime] 9:01:46
[memory] 54.73 MB
[messages] 828


补充下,以上的数据并没有限制“最大历史消息数量”。
而且同个进程内还有一个简陋的 Flask 服务。

from wxpy.

youfou avatar youfou commented on April 28, 2024

@teli5200 如果确实群消息非常多,可以考虑设置下最大历史消息保存数量
http://wxpy.readthedocs.io/zh/latest/messages.html#wxpy.Messages.max_history

bot.messages.max_history = 100

自己查了下源码,暂时无法通过设为 0 来关闭记录,算是 BUG [囧]
不过可以先设个小一点数目,1 也可以。

from wxpy.

teli5200 avatar teli5200 commented on April 28, 2024

好的,我来继续跟踪下,有问题跟你反映,谢谢

from wxpy.

teli5200 avatar teli5200 commented on April 28, 2024

我也是换成flask了,之前用 dj 内存增长更加厉害 ,另外还有个问题 ,有个微信号,有5000个好友,这个号登上去需要花费时间非常多,而且会消耗约 50M左右的内存,上去后过会会掉线,其他好友少的微信正常

刚好在这里一起说个问题,比如用家庭宽带挂微信的话,隔10几个小时之后发消息会出现返回 1100 错误,初步判断是因为家庭宽带电信限制了在线时间导致重新拨号引起,就是说链路换了,这种错误能否检测到,并且重新登录上去

from wxpy.

teli5200 avatar teli5200 commented on April 28, 2024

bot.messages.max_history = 1 这个设置后内存占用减少了一半多,但是还是会缓慢增长

from wxpy.

youfou avatar youfou commented on April 28, 2024

@teli5200 线上版本已支持通过设置 bot.messages.max_history = 0 来关闭消息记录功能
1100~1102 错误似乎与登陆状态之类的有关,包括 IP 变更等,使用固定 IP 的服务器可能会好一些。

from wxpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.