Closed gpanders closed 2 years ago
Thanks for the report, I'll look into it.
Here's an even simpler reproduction:
local uv = require('luv')
local req = uv.fs_scandir('.')
As pointed out in the OP, we currently only handle cleanup when we fully iterate with scandir_next.
Using
fs_scandir
andfs_scandir_next
as an iterator results in a memory leak if the iterator is not fully drained. Example:This results in a memory leak. This happens because the
uv_fs_req
is only cleaned up when the iterator reaches aUV_EOF
:https://github.com/luvit/luv/blob/c51e7052ec4f0a25058f70c1b4ee99dd36180e59/src/fs.c#L600-L605
However, when the iteration loop breaks early this condition is never hit and
uv_fs_req_cleanup
is never called.It does not seem possible to manually cleanup the
fs
handles either:fs:close()
does not exist.