HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Which CLR Stored Proc is causing memory pressure leading to sqlservr.exe terminating unexpectedly?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
storedleadingexepressuresqlservrclrterminatingprocunexpectedlycausing

Problem

Every few days my SQL Server Instance terminates unexpectedly and restarts.
In the logs, see:


A fatal error occurred in the .NET Framework common language runtime. SQL Server is shutting down. (Event ID 6536).

Prior to the termination I see several messages saying:


AppDomain XXX is marked for unload due to memory pressure.

I have 60 CLR Stored Procedures, which I've inherited from my predecessor. All are supposed to be short stored procedures using a small amount of data. How do I find which CLR Stored Procedure is causing the memory pressure?

I'm running:

Microsoft SQL Server 2016 (SP1-CU4) (KB4024305) - 13.0.4446.0 (X64) Jul 16 2017 18:08:49
Standard Edition (64-bit) on Windows Server 2016 Standard 6.3 (Build 14393: ) (Hypervisor)

Solution

Which CLR Stored Proc is causing memory pressure leading to sqlservr.exe terminating unexpectedly?

SAFE CLR procedures do not crash SQL Server, so looking at the managed memory usage of CLR is unlikely to lead you to the root cause.

It's more likely that you have unsafe CLR code interacting with native code that has a memory leak. So look at any the CLR projects for any use of 3rd party native components (like OleDB or ODBC drivers), or any use of P/Invoke or COM Interop.

Context

StackExchange Database Administrators Q#204350, answer score: 4

Revisions (0)

No revisions yet.