[Ironruby-core] Memory Usage Tests

Aaron Clauson lists at ruby-forum.com
Sat Jul 12 08:59:52 EDT 2008


Hi All,

In order to track down some high memory usage problems I have in a
server process that is using the IronRuby engine I have run a test using
a single line script and have encountered an issue that looks
suspiciously like a memory leak. I'm scouring through the IronRuby code
commenting out a few static lists as I find them to see if they make any
difference but to date haven't come across anything useful.

The test I'm running is:

static void Main(string[] args)
{
  ScriptRuntime scriptRuntime = IronRuby.CreateRuntime();

  for (int index = 0; index < 1000; index++)
  {
    ScriptScope rubyScope = scriptRuntime.CreateScope("IronRuby");
    rubyScope.Execute("print 'execute\n'");
  }

  Console.WriteLine("finished");
  Console.ReadLine();
}

Executing this three times on 3 separate runs the resultant process had
memory allocations of the folowing amounts as shown in the Windows Task
Manager:

31,940k
31,936k
31,936k

Executing the loop 10,000 times on 3 separate runs resulted in memory
usage of:

133,648k
134,036k
133,808k

Changing to

static void Main(string[] args)
{
  for (int index = 0; index < 1000; index++)
  {
    Console.WriteLine("execute");
  }

  Console.WriteLine("finished");
  Console.ReadLine();
}

For 1,000 iterations memory usage was 8,402k.
For 10,000 iterations memory usage was 8,704k.
For 1,000,000 iterations memory usage was 9,348.

The reason I'm looking into this is that I am having to jeep a close eye
on my server process and re-start it every 3 or 4 days when the memory
usage gets up to 300 to 400MB.

Regards,

Aaron
-- 
Posted via http://www.ruby-forum.com/.


More information about the Ironruby-core mailing list