It is sometimes useful to get the application in a bad situation to see how it reacts. Things like disconnecting a network cable or turning off the power will show me how stable my application is and where I should work.
To this end, I am trying to figure out what is the fastest way to force OutOfMemoryExceptionin .Net. Running this in a simple console application will allow me to include this script in a running application. Obviously, there are other things to consider when working with OutOfMemoryExceptions(for example, memory fragmentation and how the garbage collector allocated different generations), but this is not important for the volume of this experiment.
Update
To clarify the purpose of the question, it is important to note that a simple memory exception is not useful, since I want to see how the program will respond when the memory pressure increases. In essence, I want to stimulate the GC into an aggressive collection mode and monitor how this affects performance until the process disappears due to an exception from memory.
source
share