I imagine that there's one of two things going on here.

1. libuv is always listing the entire contents of the directory and giving them to you (regardless of how many entries there are)
2. To actually read *all* of the entries of a directory, you need to continue to call `readdir`.

I would hope that case 1 is not true, and if case 2 is true then this probably warrants some more documentation. I couldn't find a lot of info on `uv_fs_readdir` on the web, but it's hard to imagine that libuv would allocate huge amounts of memory by default when listing directories with lots of files. Do you know how libuv's directory reading works?