'How to generate heap overflow error using c#

I want generate a heap overflow error and slow down the system, however I have created alot of objects on class level, later on creating that class object millions times and passing object into GC.KeepAlvie method using loop. Still I am not able to generate the error or slow down the system



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source