kenichi / angelo

Sinatra-like DSL for Reel that supports WebSockets and SSE
Other
303 stars 23 forks source link

fix: responder not being recycled by GC for long live connection #73

Closed respire closed 7 years ago

respire commented 7 years ago

Description: after each request, server will push responder into an array. if connection is alive for a long time, responders and objects they refer to won't be recycled by GC, which may result in out of memory issue.

Solution: push Proc instead of responder if on_close block defined.

kenichi commented 7 years ago

hi @respire thanks, i believe i understand the issue. the purpose of the on_close was to do cleanup on the stashes so that the next iteration wouldn't have to; in that sense, the proc would probably retain scope of the responder, and this wouldn't get us anything. it took me a second to notice that you're only adding to the list if on_close is set, i like that.

happy to merge if you would be willing to add a test or two around it?

respire commented 7 years ago

thanks @kenichi ! of course I would love to add some specs on it. one thing, can you provide some actual scenario or case to use the on_close? actually, i'm not so understand what it's to clean up. maybe I can try to optimize the memory footprint of the on_close if I know what it did

respire commented 7 years ago

please see #74 which i think it's a better solution