Sample Code :
Static void main(string[] args) { Class1 c1 = new Class1(); }
Class1 { Class1() { Class2 c2 = new Class2(); } }
Class2 { Class2() { Class1 c1 = new Class1(); } }
The above code throws StackOverFlowException. Here we are creating Class1 & Class2 objects recursively. Objects are stored in Heap, then why it is not throwing HeapOversizedException or someotherException Related to Heap?
OutOfMemoryException.OutOfMemoryExceptionthis is Stack which refers to Thread's Execution Stack