Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When the system goes out of memory a OutOfMemoryException is thrown. Similarly for stack overflow a StackOverFlorException is thrown. Now typically an exception is thrown as follows (or the corresponding native way)
throw new System.OutOfMemoryException();
But when the system is already out of memory there's a little chance that creating an exception object will succeed. So how does the CLR create these exception objects?
The answer is trivial and as expect, at the very application start it creates all these exception objects and stores them in a static list. In case these exceptions are to be thrown then it is fetched from this list and thrown.
The consequence of handling Stack overflow is even bigger because once the stack has overflown calling even a single method in that thread is equally dangerous and can cause further corruption. That is the material for another post :)
Anonymous
April 29, 2008
PingBack from http://microsoftnews.askpcdoc.com/tech/trivia-how-does-clr-create-an-outofmemoryexception
Anonymous
April 29, 2008
Does that mean all Exception classes in System namespace is mainted or only the Offerflow ones???
Pretty interesting
Anonymous
April 29, 2008
Not all but only the ones that can have problems being created later.
Anonymous
May 08, 2008
same is true for StackOverflowException.
Please sign in to use this experience.
Sign in