public virtual void TestChainedEstimation()
{
Random rnd = Random();
Entry first = new Entry();
try
{
while (true)
{
// Check the current memory consumption and provide the estimate.
long jvmUsed = GC.GetTotalMemory(false);
long estimated = RamUsageEstimator.SizeOf(first);
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0000000000}, {1:0000000000}", jvmUsed, estimated));
// Make a batch of objects.
for (int i = 0; i < 5000; i++)
{
first.CreateNext(new sbyte[rnd.Next(1024)]);
}
}
}
catch (System.OutOfMemoryException e)
{
// Release and quit.
}
}