How to kill a machine with five lines of code...

time to read 2 min | 374 words

Unfortunately, I just run into this "issue", check this out. In the context of an ASP.Net page, put this code;

 

This code run for a couple of minutes before I noticed something wrong. Suddenly my machine was very slow an unresponsive. At first I suspected the devenv.exe process, which is getting pretty heavy lately (mainly because of ReSharper, to be honest.) When I managed to load the TaskManager, I found the aspnet wp.exe process was consuming over 700Mb of memory, and was swapping like mad. It had over a million page faults, and was advancing fast to oblivion. The machine has 1Gb memory, and it used 1.8Gb, just to give you an idea about the pain this machine had suffered.

This tiny piece of code managed to:

  Eat 100% CPU.

  Push all other memories from memory.

  Push itself out of memory, so each loop iteration caused several page faults.

  Clear the pre fetched cache, so any new applications that I load will load much slower.

Pretty impressive, all in all. And all I forgot is a single line of code that would advance the current time.