During some process, I'm storing objects to a file (serialization). Each batch will store 100 files. I'm quickly getting "Too many open files" error.
I'm closing the StreamWriter immediately after usage and I also tried to dispose the file. I'm having a multithread application, but I centralised the storage into a single thread to make sure that there are no more then X operations in parallel. I'm now even storing object by object (one at a time) and i'm still getting this error.
It looks like "closing" or "disposing" the StreamWriter is not enough. Any idea someone?
I tried a lot of different code, but this is my current code:
Log.i("Streamwriter opened");
StreamWriter outfile = new StreamWriter (filePath);
outfile.Write (content);
outfile.Close ();
outfile.Dispose ();
Log.i("Streamwriter closed");
I printed it also out to make sure that "opening" a file is always immediatly followed by "closing" a file.
Any ideas?