If I run the following program I see the free memory rapidly decrease to zero in Windows Task manager. Is it forbidden to use NSubstitute in loops?
using System;
using NSubstitute;
using System.Threading;
namespace NSubstituteMemoryLeaks
{
class Program
{
static void Main(string[] args)
{
IConfig config = Substitute.For<IConfig>();
config.Value.Returns(0);
Thread th = new Thread(() => {
while (true)
{
int val = config.Value;
}
});
th.IsBackground = true;
th.Start();
Console.WriteLine("Press ENTER to stop...");
Console.ReadLine();
}
}
public interface IConfig
{
int Value { get; set; }
}
}