0

Is there a way to control memory consumption in .NET globally?

I am aware of MemoryFailPoint but I need to restrict it globally in my whole app. MemoryFailPoint needs to be created for each next operation - and get disposed.

And since I am doing something heavily palatalized, I am not sure if MemoryFailPoint would not meddle with TPL.

Just for fun instantiate an instance of this class:

class Bomb
{
    public Bomb()
    {
        var t = new Task<Bomb>(() => new Bomb());
        t.Start();

        t.Wait();
        Next = t.Result;
    }

    string TNT = new string('*', 1024 * 640);

    public Bomb Next;
}
svick
  • 236,525
  • 50
  • 385
  • 514
Kaveh Shahbazian
  • 13,088
  • 13
  • 80
  • 139
  • Nothing direct, but this question addresses the problem too: http://stackoverflow.com/questions/4852062/limiting-process-memory-with-maxworkingset – Adam Houldsworth May 29 '13 at 14:48
  • 1
    Could you explain in more detail why are you trying to do this? Are you trying to protect against potentially buggy plug-in, or something like that? – svick May 29 '13 at 16:41

0 Answers0