I am occasionally getting the "Memory Usage Maxed Out - 4096MB max" error when backtesting a Daily-resolution algorithm, so I started logging the memory utlilization (GC.GetTotalMemory) at the end of each day.  

The interesting thing is that the same algorithm with the same parameters and making the same trades is seeing vastly different memory utilization on different runs.  Most of the time, my memory utlization is maintaining an average of around 1G.  On some runs, however, memory utilization starts at close to 2M after Day 1 and steadily creeps upwards, as if the garbage collection on the VM instance is not performing or something.

Any ideas/suggestions?

Thanks.

Author