Page 1 of 1

PHP SplFileInfo: "Too many open files"

Posted: Fri Mar 10, 2017 2:37 pm
by peter_b
[PROBLEM]
Storing clones of SplFileInfo objects in an array to sort them, throws the following error:
failed to open dir: Too many open files in [...]
[SOLUTION]
If only I had seen Ken Snyder's comment on PHP DirectoryIterator's documentation page before:
Don't store DirectoryIterator objects for later; you will get an error saying "too many open files" when you store more than the operating system limit (usually 256 or 1024).