我正在運行帶有服務使用的數據庫的Sql Server 2008 R2 Express。數據庫在服務啓動時通過AttachDBFileName選項附加。該服務不斷運行並且僅在自動更新後重新啓動。由於內存壓力,Sql Server 2008 R2:AppDomain被標記爲卸載
有時候,這種模式出現在SQL Server日誌:
10/09/2013 11:18:05,spid18s,Unknown,AppDomain 6 (..MDF.dbo[runtime].5) unloaded.
10/09/2013 11:18:05,spid1s,Unknown,AppDomain 6 (...MDF.dbo[runtime].5) is marked for unload due to memory pressure.
10/09/2013 11:16:16,spid53,Unknown,AppDomain 6 (....MDF.dbo[runtime].5) created.
10/09/2013 11:16:00,spid28s,Unknown,AppDomain 5 (....MDF.dbo[runtime].4) unloaded.
10/09/2013 11:16:00,spid1s,Unknown,AppDomain 5 (....MDF.dbo[runtime].4) is marked for unload due to memory pressure.
10/09/2013 11:15:41,spid53,Unknown,AppDomain 5 (...MDF.dbo[runtime].4) created.
10/09/2013 11:14:20,spid24s,Unknown,AppDomain 4 (...MDF.dbo[runtime].3) unloaded.
10/09/2013 11:14:20,spid1s,Unknown,AppDomain 4 (...MDF.dbo[runtime].3) is marked for unload due to memory pressure.
這會導致性能問題,因爲每次在AppDomain重新啓動時,緩衝區被丟棄,數據庫沒有響應幾秒鐘。
根據http://support.microsoft.com/kb/917271?wa=wsignin1.0,這可能是由於內存泄漏或CLR模塊中的其他錯誤(即使我認爲應該在Sql Server 2008 R2中修復)。有安裝了一個CLR模塊,用以下代碼:
[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(Format.UserDefined,
MaxByteSize=8000)]
public class Concatenate : IBinarySerialize
{
/// <summary>
/// The variable that holds the intermediate result of the concatenation
/// </summary>
private StringBuilder intermediateResult;
public void Init()
{
// Put your code here
intermediateResult = new StringBuilder();
}
public void Accumulate(SqlString Value)
{
if (Value.IsNull)
return;
intermediateResult.Append(Value.Value).Append(", ");
}
public void Merge(Concatenate Group)
{
intermediateResult.Append(Group.intermediateResult);
}
public SqlString Terminate()
{
string output = string.Empty;
//delete the trailing comma, if any
if (intermediateResult != null && intermediateResult.Length > 0)
output = intermediateResult.ToString(0, intermediateResult.Length - 2);
return new SqlString(output);
}
#region IBinarySerialize Members
public void Read(System.IO.BinaryReader r)
{
if (r == null) throw new ArgumentNullException("r");
intermediateResult = new StringBuilder(r.ReadString());
}
public void Write(System.IO.BinaryWriter w)
{
if (w == null) throw new ArgumentNullException("w");
w.Write(intermediateResult.ToString());
}
#endregion
}
此外,MS交換在服務器上運行,使用的對MDB商店自由存儲器高達90%。然而,我發現過去在其他帶有大量空閒內存的服務器上出現這樣的錯誤,所以我認爲內存壓力並不是問題的真正原因。
任何想法可能會導致此問題?
你寫了一個事實陳述在這裏。問題是什麼? –