Lua socket library not properly closing connections leading to resource exhaustion
I tried several approaches but none seem to work. I'm using LuaSocket (version 3.0-rc1) for a simple TCP server that serves multiple clients. After running the server for a while, I've noticed that it starts consuming more memory and eventually crashes with an "Out of memory" behavior. I've verified that the clients are disconnecting, but it seems that the server doesn't properly close the connections and clean up resources. Here's a simplified version of my server code: ```lua local socket = require("socket") local server = assert(socket.bind("*", 12345)) server:settimeout(0) while true do local client = server:accept() if client then client:settimeout(10) local line, err = client:receive() if not err then client:send(line .. '\n') end client:close() -- Closing client connection end socket.sleep(0.01) end ``` I've tried adding `client:close()` after processing each client, but it doesn't seem to help. I've also enabled garbage collection using `collectgarbage()`, but that doesn't resolve the scenario either. I'm running this on Lua 5.4.3, and I suspect there might be something about how connections are handled when they drop unexpectedly or if the accept loop is too fast. Is there a known best practice for managing socket connections in Lua to avoid this type of resource leakage? Any advice on diagnosing or resolving this would be greatly appreciated! I'm working on a application that needs to handle this. Thanks in advance!