Created
January 28, 2013 16:02
-
-
Save keichi/4656726 to your computer and use it in GitHub Desktop.
This simple code causes memory leak on Mono 2.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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