Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>An OOM condition generally occurs when you are either running out of system memory, or in a 32 bit process you are out of address space(2000MB).</p> <p>You say it can successfully copy one but not two? Is that two concurrently or consecutively? What is your threading model? Also, the example is a snippet, you seem to have a StreamWriter and a Stream for writing, are these objects going away?</p> <p>Be careful with GC.Collect. Microsoft doesn't recommend explicit calls because if you don't use it correctly it can cause objects to stay alive longer than needed. This is because when you do a GC.Collect, you are promoting objects to a higher generation. In my experience it is best to make sure you are releasing objects and let the framework decide what/when to GC.Collect.</p> <p>I would get familiar with WinDBG+SOS, this allows you to look at the objects on the heap.</p> <p>Try this:</p> <ol> <li>Startup WinDBG and attach to your process</li> <li>Type ".loadby sos clr" if using 4.0, otherwise type ".loadby sos mscorwks"</li> <li>Press F5 to continue</li> <li>Copy one file, wait for it to complete</li> <li>Press CTRL+BREAK</li> <li>Type "!dumpheap -stat", look at the results, look for objects that should be gone</li> <li>For-Each object that should be gone, grab the MT value</li> <li>Type "!dumpheap -mt {0}" replacing {0} with the value from step above</li> <li>This is a list of instances, grab one of the objects addresses</li> <li>Type "!gcroot {0}" replacing {0} with the objects address</li> </ol> <p>This should tell you what is rooting the objects, you then need to find out how to unroot, e.g. null objects that aren't needed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload