小编use*_*662的帖子

cassandra c#驱动程序内存泄漏

使用cassandra .net驱动程序,我们面临以下问题:当使用参数化INSERT插入大量行时,应用程序内存使用量不断增长:

class Program
{
    static Cluster cluster = Cluster.Builder()
        .AddContactPoints(ConfigurationManager.AppSettings["address"])
        .Build();
    static Session session = cluster
        .Connect(ConfigurationManager.AppSettings["keyspace"]);
    static int counter = 0;

    static void Main(string[] args)
    {
        for (int i = 0; i < 50; i++)
        {
            new Thread(() =>
            {
                while (true)
                {
                    new Person()
                    {
                        Name = Interlocked.Increment(ref counter).ToString(),
                        ID = Guid.NewGuid(),
                        Data = new byte[4096],
                    }.Save(session);
                }
            }).Start();
        }

        Console.ReadLine();
    }
}

class Person
{
    public Guid ID
    {
        get;
        set;
    }

    public string Name
    { …
Run Code Online (Sandbox Code Playgroud)

c# memory-leaks cassandra

5
推荐指数
2
解决办法
1112
查看次数

标签 统计

c# ×1

cassandra ×1

memory-leaks ×1