ember-websockets icon indicating copy to clipboard operation
ember-websockets copied to clipboard

closeSocketFor does not destroy the web socket and causes memory leak

Open sethphillips opened this issue 5 years ago • 3 comments

we tracked down a memory leak in our application that led us to sockets hanging around. turns out that the delete get(this, 'sockets')[cleanedUrl]; removes the reference but does not destroy the proxyObject. Getting that socket proxyObject and calling destroy() on it does remove it from memory though.
Happy to submit a PR if you need.

sethphillips avatar Jun 19 '19 01:06 sethphillips

@sethphillips how are you destroying the proxyObject?

cmackenz avatar Aug 31 '20 21:08 cmackenz

the proxyObject is returned from the socketFor method on the service.

@service websockets;
//...... random code
let socket = this.websockets.socketFor(someurl);
//...... random code 
socket.destroy()

sethphillips avatar Aug 31 '20 21:08 sethphillips

@sethphillips thanks!

cmackenz avatar Aug 31 '20 21:08 cmackenz