Memory pressure notification in SQL CLR
Google is not able to tell开发者_StackOverflow社区 me if there is an API available inside the SQL CLR to get memory pressure notification.
It is obviously used, since the AppDomain will get unloaded under memory pressure, but the question is if the notification is sent to into the AppDomain prior to the unload, so that I could release some cache memory.
(My dll is already running in unsafe mode, so that is a non-issue)
In SQL 2012, they implemented a new query that allows you to get the current memory usage...
select survived_memory_kb from sys.dm_clr_appdomains where db_id = DB_ID()
It doesn't give you the memory pressure, but it does allow you to monitor the usage of memory, and thus adjust based on your own logic.
精彩评论