Skip to content

Instantly share code, notes, and snippets.

@keichi
Created January 28, 2013 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keichi/4656726 to your computer and use it in GitHub Desktop.
Save keichi/4656726 to your computer and use it in GitHub Desktop.
This simple code causes memory leak on Mono 2.x
using System;
namespace MemoryLeakTest
{
class MainClass
{
public static void Main (string[] args)
{
for (;;) {
var testArray = new TestStruct[500 * 500 * 50];
var totalMemory = GC.GetTotalMemory(false);
Console.WriteLine("total mem = {0}MB", totalMemory / 1024 / 1024);
GC.Collect();
System.Threading.Thread.Sleep(1000);
}
}
}
struct TestStruct
{
public int field1;
public int field2;
public int field3;
public int field4;
public int field5;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment