jeudi 5 mai 2016

IOException when memory low

I have the following line of code:

CSharpCodeProvider c = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters();
cp.ReferencedAssemblies.Add("system.dll");
cp.CompilerOptions = "/t:library";
cp.GenerateInMemory = true;
CompilerResults cr = c.CompileAssemblyFromSource(cp, sb.ToString());

Which results in an IOException being thrown.

Additional information: The process cannot access the file 'C:\Users\Username\AppData\Local\Temp\dgl5fb1i.err' because it is being used by another process.

However, this is a part of a large program that consumes more than 8GB of RAM. On a system with 16GB of RAM, this exception is not thrown. The code that is dynamically compiled compiles well and runs. The program runs without any errors on a system with sufficient RAM. The program is compiled for x64. Note that I am not getting OutOfMemoryException or any indication that the program is out of memory. In the Task Manager the memory usage almost reaches the top before the IOException is thrown.

What could be causing this behavior and can anyone suggest a solution?





Aucun commentaire:

Enregistrer un commentaire