I have a Windows service that is retrieving a few selected files from a directory that contains millions of other files. The service runs out of memory every hour or so. This never happened when there were a few thousand, so it feels like some resource is not being properly disposed of. But to my eyes the stream is being disposed of properly.
using (FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read))
{
//deserializes the file with a binary formatter
}
The directory itself is marked as compressed, so I also wonder whether this is contributing to the problem.
Can anyone explain the cause of this apparent memory leak?