URLSessionWebSocketTask cause memory leak when it is disconnected

We use URLSessionWebSocketTask in our app, whenever we call disconnect which triggers cancel method on URLSessionWebSocketTask, it triggers memory leaks. I used memory graph inside Xcode to find the memory leaks.


I created an example project to show the memory leaks. Please see FB7729600 for details.

I had lab time with Apple developer this morning but we were running out of time. I tried the approach suggested to avoid use self inside addListener, replace it with static property. I still see memory leak.

Any suggestion is welcome!
Hi Yilei,

I went through the Feedback and noticed that you are running this on 17G5035d ?

We have some WebSocket changes that we landed in 17G5045c (13.6 beta 2).

It might also be a fine idea to test this on iOS 14.

Looking at your code once again, and I think capturing weak self should be fine and should not cause a cycle
Thank you. I will keep eye on this to see if it is fixed on iOS 14. Thanks!
Hi all, Im receiving the same memory leaks and tried it on both ios 13.6 and 14 betas; the memory leak still persists in both. Is it possible to get a fix on this for ie 13.6.1 or come up with an agreed solution?
URLSessionWebSocketTask cause memory leak when it is disconnected
 
 
Q