Large sends can cause memory issues
To stress test my websocket server, I wrote a debug endpoint that puts a file full of an arbitrary amount of zeros -- 5MiB at time of writing -- into a string using file_get_contents(), calculates the string length using strlen(), and sends the data and the length metadata to the connection. If I fire off 5 such requests in rapid succession, I notice my ws server memory and cpu usage spike severely, and the memory remains locked up long afterward the connection is closed, requiring the server to be reset. I'm even explicitly calling unset() on the string full of zeros immediately after sending the response, but the memory remains locked up. Is it possible that buffers used for a given connection aren't getting cleaned up on connection close, and if so, is there a known solution to this?