I thought perhaps some more info on reproducing the issue would help.
Take the following NUnit test code.
[Test]
public void MakeMemoryLeak()
{
for (int i = 0; i < 1000; i++)
{
MockManager.Init();
MockManager.MockObject(typeof(IList), Constructor.Mocked);
MockManager.Verify();
}
}
Now, before running the test, go into Perfmon and add the following counters.
.NET CLR Loading -> Bytes in Loader Heap
.NET CLR Loading -> Current Assemblies
Note that when the test is run, the # of assemblies loaded quickly rises to over the 1000 mark, and the total bytes in the loader heap also rises as the assemblies are loaded.
Is there a way to stop this? Can the interface mock be created before MockManager.Init, which would allow us to use a single instance for all our mocking?