I would like to write the following code in c#. a) small console application that simulates memory leak. b) small console application that would invoke the above application and
The leaking application might look like:
public static void Main()
{
var list = new List();
while (true)
{
list.Add(new byte[1024]); // Change the size here.
Thread.Sleep(100); // Change the wait time here.
}
}
And the calling application might look like:
public static void Main()
{
Process process = Process.Start("leaker.exe");
process.Kill();
}
Take a look at the properties on the Process class. There are several that return how much memory the process is consuming. You may be able to use one of them to conditionally kill the process.