-
-
Notifications
You must be signed in to change notification settings - Fork 895
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
Flask SocketIO memory leak and WebSocket Breaks frequently (During high frequency of data emission) #264
Comments
You don't seem to be using the original example, since in your videos the events go at a much higher rate. Can you share your version of the code? |
Hello, As said earlier in Step.1 point.4 & 5, I have only changed the data content and its size is changed to 21KB. Most importantly, I changed Data emit rate to time.sleep(0.05). Here, Data-emit rate is kept high just to reproduce issue fast enough rather waiting for issue to reproduce post couple of days. Where code version of sample example be visible? I have shared the version details of packages. Regards, |
Hello Miguel, And running yours sample example of Flask-socketIO-2.0 "Flask-SocketIO-master.zip" I just did a diff between my example copy and latest example copy available is changes in directory 'flask_socketio', test_socketio.py and setup.py. This changes were done a day ago i suppose. Anyway, i am not using these files. Let me know if i need to provide additional info. Regards, |
You described the changes you made to the script, but you haven't provided them. It would be best if you give me the exact script you are using, instead of me trying to figure out the changes on my own. Just commit them to your fork of the project and I'll get the files from there. Thanks. |
As request, please find attached example.zip along with below changes. Changes are in app.py, and index.html. New additions are static directory and there-in js files. Changes are tagged with 'vipuljain'
templates Let me know if you are able to download the attachment and run the sample test. |
I suppose the directory listing was disturbed, updated again as below. |
Well, using your application I don't really see continuously growing use of memory. On my system memory kept growing for about 4 minutes, then stabilized and stayed the same for a long time. I think what you are seeing is the Python's not terribly effective memory management of those large strings you are creating. Note that I was able to make the process consume less memory by storing the result of |
Update: I left the script running for over an hour and I don't see any change in memory usage. |
Hello Miguel, I had captured observations using Google chrome Version 48.0.2564.109m with app.py running on python2.7 base platform on Debian linux. I would like to replicate your setup details at my end if you can share your setup details where you ran app.py application. One thing i would like to know - were you able to see JSON data on browser continuously even after an hour. Because, by that time the browser memory may have crossed 1GB i assume. I would request you to see attached videos once again and try to observe detailed step-2 and step-3 (as mentioned in earlier post).
In addition, you also try - do not let web-socket connection establish and instead transport polling will take care. Observe memory leaks alongwith data to be observed on browser. Regards, |
If I'm not mistaken, the entire period covered in your last screenshots is about two minutes. As I said above, in my testing it took about 4-5 minutes for memory to reach a balance. Also, to avoid Chrome using too much memory you can comment out the code that adds those payloads to the DOM. Then Chrome will not use much memory and can stay up for a long period of time. |
I gave it another run today, and I still don't see any evidence of memory leaks.
|
This issue felt through the cracks. A while ago I have addressed a newly discovered socket leak that is probably what is reported here. Please upgrade all dependencies to the latest versions and retest. Reopen if you still have leaks. |
Hello Miguel,
Thanks for continued support. But this time, i again had observations of memory leak. Please refer videos for better clarity.
I have below Flask SocketIO-2.0 setup.
1.Flask-SocketIO-2.0.tar.gz
2.python-socketio-1.0.tar.gz
3.python-engineio-0.8.7.tar.gz
And running yours sample example of Flask-socketIO-2.0
Flask-SocketIO-master.zip
To run sample of Flask-SocketIO-2.0, please install this - gevent-socketio-0.3.6.tar.gz
I had below observations using Google Chrome. I have uploaded the video for your reference.
Step-1: At Initial, (Refer video ‘01 InitWebsocket.mp4’ at url https://www.dropbox.com/l/s/UM2SlTS2Ep7V6cvtLK3udu
Step-2: After few minutes i.e. Approx. 3 minutes, (Refer video ‘02 WebSocketMemoryLeak.mp4’ at url https://www.dropbox.com/l/s/MQRACKo8qdv8elUPjNckQo
Memory consumption is still 2.2%
Step-3: Actually, in step-2, web-socket connection was able to establish. But now in step-3, I would make changes in browser settings to block web-socket connection permanently and instead let polling mechanism
only occur frequently. This change is made to notice that Memory Leak also happens heavily during polling and while closing the browser and re-opening the browser page.
Refer video 03 PollingMemLeak.mp4 at url https://www.dropbox.com/l/s/urnBdMkJqjt0aEcUHJCahr
Observations/Summary for Step2 and Step3:
Step-2:
Step-3
I am looking for below options
I have posted this issue on your blog - discussion thread #326, #327
Thanks & Regards,
Jain
The text was updated successfully, but these errors were encountered: