Open treeeast opened 6 years ago
你这每隔3分钟加载了一次二维码,大概二维码没释放
itchat.auto_login(enableCmdQR=2)
import sys print(sys.getsizeof('itchatsize{}'.format(itchat)))
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对象一直在增加?
原先的代码就不贴了,主要是实现准点提醒,但运行一天后,内存消耗竟然在2G多。 调试下,写了个最简单的代码。如下: import itchat import time
while True: itchat.auto_login(hotReload=True, enableCmdQR=False) time.sleep(180)
随着时间推移,内存消耗也越来越大。怎么回事啊?求解