DO.Net 4.3 RC2 seems to contain a small memory leak. (Not tested on other versions)

Here is a test project: [attachment=0:35ctcl8e]TestLeak.zip[/attachment:35ctcl8e]

I'm doing in a loop a very simple query and I execute GC.Collect() every 100 calls to get a smooth memory usage curve.

while (true)
      {
        if (count % 100 == 0)
        {
          GC.Collect();
          Console.WriteLine(count);
        }

        PerformTestQuery(domain);

        count++;
      }

private static void PerformTestQuery(Domain domain)
    {
      using (Session.Open(domain))
      {
        using (var transactionScope = Transaction.Open())
        {
          MyEntity entity = Query.All<MyEntity>().First();

          var query = (from i in entity.Items
                       select i.Id).Take(100);
          query.ToList();
        }
      }
    }

Memory usage (Private bytes) * after start : 55Mo * 1 hour later : 160 Mo * 2h10 later : 280 Mo * 3h40 later : 450 Mo

The rise is slow, but noticeable as our application runs as a service.

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Jun 02 '10 at 16:08

olorin's gravatar image

olorin
358848792


One Answer:

To be checked ASAP. It looks like there is really something wrong, since in v4.3 we intentionally reduced cache sizes so that most of DO4 Domains shouldn't use >256Mb of RAM. Moreover, in your case RAM is constantly consumed on pretty simple task executed repeatedly, so there is almost 100% some leak.


The bug is found: our implementation of weak reference-based cache never cleans up its internal dictionary, if AddNewItem/GetExistingItem operation ratio is (in average) higher then certain number. Or, shortly, if most of requests lead to addition of items to this cache, it starts to waste RAM, because its internal dictionary is always growing.

We'll fix the issue today, so most likely, updated DO installers will be published on this weekend or on Monday.

answered Jun 02 '10 at 16:44

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA