littlecodersh / ItChat

A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
http://itchat.readthedocs.io
MIT License
25.67k stars 5.65k forks source link

Ithcat是否存在内存泄漏的问题呢 #645

Open treeeast opened 6 years ago

treeeast commented 6 years ago

原先的代码就不贴了,主要是实现准点提醒,但运行一天后,内存消耗竟然在2G多。 调试下,写了个最简单的代码。如下: import itchat import time

while True: itchat.auto_login(hotReload=True, enableCmdQR=False) time.sleep(180)

随着时间推移,内存消耗也越来越大。怎么回事啊?求解

ipfans commented 6 years ago

你这每隔3分钟加载了一次二维码,大概二维码没释放

swissfiscal commented 6 years ago

itchat.auto_login(enableCmdQR=2)

itchat.auto_login()

import sys print(sys.getsizeof('itchatsize{}'.format(itchat)))

toUserName = list[0]['UserName']

import urllib.parse app = Flask(name) @app.route("/wx/sendMessage",methods=["GET","POST"]) def send_wechat_message(): if request.method == "POST": message = request.form['message'] toUserName1 = request.form['toUserName'] print(message) print(toUserName1) s=urllib.parse.unquote(toUserName1) print(s) list = itchat.search_chatrooms(name=toUserName1) toUserName = list[0]['UserName'] for i in range(3): itchat.send(message, toUserName=toUserName) resource.getrusage(resource.RUSAGE_SELF).ru_maxrss return 'message sent successfully'

============================= 我这个代码也一直在增长内存,是不是因为接收到的消息太多,itchat对象一直在增加?