SOS is a memory monitoring tool provided by VS. It can monitor memory data in real time during debugging.
Before using SOS, you must first understand several common debugging concepts.
Managed code and unmanaged code:
Managed Code:
Managed code is code written in one of over twenty high-level programming languages that are available for use with the Microsoft. NET Framework, including C #, J #, Microsoft Visual Basic. NET, Microsoft JScript. NET, and C ++. all of these versions share a uniied set of class libraries and can be encoded into an Intermediate Language (IL ). A runtime-aware compiler compiles the IL into native executable code within a managed execution environment that ensures type safety, array bound and index checking, exception handling, and garbage collection.
Common managed code:
1. Code that is executed by the CLR.
2. Code that targets the common language runtime, the foundation of the. NET Framework, is known as managed code.
3. managed code supplies the metadata necessary for the CLR to provide services such as memory management, cross-language integration, code access security, and 4. 4. automatic life time control of objects. all code based on IL executes as managed code.
Code that executes under the CLI execution environment.
Managed Debugging: Managed Debugging
Debugging only for hosted code is called hosting debugging.
SOS command
! Load SOS: Start SOS. SOS cannot be loaded only when hosting debugging is executed. The solution is to enable unmanaged code debugging on the project> Properties> debugging page. Add breakpoint, Debug
! CLRStack-n
! DumpDomain
! DumpObj
! DumpHeap-type className
! DumpMT
! U methodAddress