Sql server Sql Server 2008 R2:由于内存压力,AppDomain已标记为卸载

Sql server Sql Server 2008 R2:由于内存压力,AppDomain已标记为卸载,sql-server,sql-server-2008,memory,clr,Sql Server,Sql Server 2008,Memory,Clr,我正在使用服务使用的数据库运行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 (.

我正在使用服务使用的数据库运行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时,缓冲区都会被删除,数据库会在几秒钟内无响应

根据,这可能是由于CLR模块中的内存泄漏或其他错误造成的(尽管我认为应该在SQLServer2008R2中修复)。安装了一个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
}
[可序列化]
[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(Format.UserDefined,
MaxByteSize=8000)]
公共类连接:IBinarySerialize
{
/// 
///保存连接的中间结果的变量
/// 
私有StringBuilder中间结果;
公共void Init()
{
//把你的代码放在这里
中间结果=新的StringBuilder();
}
公共无效累积(SqlString值)
{
if(Value.IsNull)
返回;
intermediateResult.Append(Value.Value).Append(“,”);
}
公共无效合并(连接组)
{
intermediateResult.Append(Group.intermediateResult);
}
公共SqlString终止()
{
字符串输出=string.Empty;
//删除后面的逗号(如果有)
if(intermediateResult!=null&&intermediateResult.Length>0)
输出=intermediateResult.ToString(0,intermediateResult.Length-2);
返回新的SqlString(输出);
}
#区域IBinarySerialize成员
公共无效读取(System.IO.BinaryReader r)
{
如果(r==null)抛出新的ArgumentNullException(“r”);
intermediateResult=新的StringBuilder(r.ReadString());
}
公共无效写入(System.IO.BinaryWriter w)
{
如果(w==null)抛出新的ArgumentNullException(“w”);
w、 写入(intermediateResult.ToString());
}
#端区
}
此外,MS Exchange正在服务器上运行,MDB存储占用了90%的可用内存。但是,我以前在其他具有大量可用内存的服务器上看到过这种错误,因此我认为内存压力不是问题的真正原因


有什么想法会导致这个问题吗?

看看这里,如果你有同样的问题,请阅读:

你在这里写了一份事实陈述。问题是什么?