我正在使用服务使用的数据库运行Sql Server 2008 R2 Express。在服务启动时通过AttachDBFileName选项附加数据库。该服务不断运行,仅在自动更新后重新启动。
有时,此模式显示在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 Exchange正在服务器上运行,使用90%的可用内存用于MDB存储。但是我在过去的其他服务器上看到了这些错误,有大量的可用内存,所以我认为内存压力不是问题的真正原因。
任何可能导致此问题的想法?
答案 0 :(得分:0)