AppDomain is marked for unload due to memory pressure.

本文探讨了在SQL Server上进行内存优化的方法,包括调整-g启动选项、使用StringBuilder进行字符串拼接、合理设置最大服务器内存等。同时,还讨论了如何通过监控性能计数器来诊断内存问题。

32-bit or 64-bit?  Have you tried tweaking the -g startup option for
sqlservr.exe?  That option configures the mem-to-leave area, which is where
SQLCLR pulls its memory from... It defaults to 256 MB on 32-bit systems, so
it might need a tweak.  Also, how are you doing the string concatenation in
your function?  Are you using StringBuilder, or the concatenation operator
(+)?  The latter could be causing part of your problem if it's what you're
using, as a lot more objects have to be allocated and deallocated than with
StringBuilder...

With regard to perf counters, the .NET counters are the most useful; there
are also a handful of DMVs you can use.  Check out Kimberly Tripp's white
paper, which talks about some of this towards the end:

http://www.sqlskills.com/resources/Whitepapers/SQL%20Server%20DBA%20Guide%20to%2
0SQLCLR.htm

 

 

-------------------------------

The amount of memory on the SQL Server would be my first concern.  1GB of RAM just isn't very much.  The OS alone can consume that relatively quickly, especially with IIS running the server as well.  Hyperthreading isn't generally recommended with SQL Server however, it has nothing to do with your problem currently, which is all memory based.  If anything having a true second core may make the Memory bottleneck that much more visible, as the processors may process faster than the memory can keep up and paging to disk begins to occur.

 

 

-------------------------------

 

You have to have significant memory issues to have both of these events happen together.  The proc cache is Bpool, and the CLR is MTL/VAS.  If you are on 32 bit SQL, then you need to set the -gparameter with 512 and it should resolve the issue with the app domain unload.  What else is running on the SQL Server?  Full Text Indexing/Integration Services/Reporting Services/IIS?  External Memory Pressure can easily trigger internal memory pressure in SQL.  If you have things other than just the SQL Database Engine running, then you may need to scale back your max server memory setting to 6GB or less, and you might consider removing the /3GB to give the 2GB  of VAS to the kernel mode since your bpool is being allocated in AWE.

 

Xprocs, Large Query Plans, connetions with a network packet size > 8060 bytes, SQLCLR, OLE Automation calls, all run in the MTL/VAS allocation taken by SQL Server.  What does your CLR Assembly do?  That is one question I have yet to see posed on this post?  Have you considered that you might have placed your CLR in the wrong place putting it in SQL Server?  What is the PermissionSet for the Assembly?  If it is UNSAFE then I would definately begin to consider that it might be doing the wrong thing inside of SQL Server.  Also check if you use XML documents in SQL that you are destroying the handles on them as this can leak memory, and if you are using OLE Automation calls that you destroy those objects properly as well.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值