Open shiqifeng2000 opened 1 year ago
I have also noticed memory leaks for each peer connection. I would suspect that there are cyclic references created by the frequent use of Arc
in this project.
This project is to a large degree a 1:1 clone of the Pion
server written in Go and thus shares the same software architecture. Go has a garbage collector that probably (my guess) can detect dead islands of cyclic references unlike in Rust where an island of cyclic Arc
references will never be freed.
From what I understand this will be a quite a large issue for long running services that rely on WebRTC. Is there a reason the issue isn't higher priority? Nice breakdown @shiqifeng2000
hi
I am trying to build an app using actix-web as an ice server, ffmpeg as video/video sample feeder and this repo as a proxy.
But after I put them together I found that each peer connection will left some few memory in the system process, after a lot of heavy visits test, the process will be killed by Linux system and quit.
At first, I found some udp connection failed to get closed after peer connection closed, which can be found from bugfix-Udp connection not close (reopen #174) #195 #202
But after it was fixed and the repo version got to 0.6, I found the memory issue is still there, each time when a peer connected a portion of 0.1% of my system memory is consumed, I guess it is likely to be some threading data issue.
this is the outcome for initial state
And here's a few connections from web
this is what I got after 5 connection is released
no sockets left
Your see, the mem is growing, even after all udp sockets are released. Ffmpeg, however, is likely to be another reason to leak memory, so I removed ffmpeg from my code, copying the code from example
play-from-disk-h264
to track the issue. Still no luck. Maybe it's because of the webrtc repo code.To prove my point, I use this repo example
play-from-disk-h264
as test subject, with an h264 and an ogg file split from a mp4 file,valgrind
,--leak-check=full
to test if any data is still reachable.This is what I got
Is this because of the tokio runtime? Or tokio task not released in your code? I'm not sure, could you examine your code to see if there's leaking issue? Thanks