Loading
Make sure that the DirectoryStream gets closed.
As the docs say, "If timely disposal of file system resources is required, the try-with-resources construct should be used to ensure that the stream's close method is invoked after the stream operations are completed." Turns out that without closing the stream, the JVM runs out of memory pretty quickly. Doing this is not optional but mandatory.