I have written the following code to check for sufficient memory,
while (true)
{
try
{
// Check for available memory.
memFailPoint = new
MemoryFailPoint checks for consecutive available memory as documented here : http://msdn.microsoft.com/fr-fr/library/system.runtime.memoryfailpoint.aspx
You may consume very little memory, but have fragmented it a lot and then be now unable to allocate a consecutive block of memory of the needed size. It's very typical of this problem to occur after a few hours. To avoid that, use a pool of object for object you keep instantiating, it will make the memory space in use more rigid.