How to collect a memory dump based on StackOverflowException


Overview

Process memory dumps are very efficient sources of information that are used for troubleshooting websites, which is the reason they are frequently requested by Sitecore Support. Various tools allow collecting the memory dumps of a specific process, both based on a user request (on-demand) and based on a specific event (conditional). This article describes how to gather memory dumps on StackOverflowException.

Description

StackOverflowException is thrown by a thread that exhausts its stack space. In .NET applications thread stack is 1 MB large. Threads might reach stack space limit either due to infinite recursion (filling stack with call frames) or by allocating a large number of value type objects into thread stack (usually, large structures). The symptom of StackOverflowException is slowness and the application crashes.
StackOverflowException is a native exception that is displayed in Windows Logs, for example:

C00000FD.STACK_OVERFLOW

Gathering Memory Dump on first chance StackOverflowException

The most efficient way to investigate StackOverflowException errors is by collecting a memory dump when the exception occurs. To collect a memory dump based on first chance StackOverflowException use the following ProcDump command:

procdump.exe -accepteula -e 1 -f C00000FD.STACK_OVERFLOW -g -ma [PID]

The resulting .dmp file includes a problematic thread and can be investigated as any other managed memory dump.

Gathering Memory Dump using ProcDump

To collect Memory Dump in different environments using ProcDump proceed with the following articles.