[Ironruby-core] Memory Leak with Certain Script Exceptions

Tomas Matousek Tomas.Matousek at microsoft.com
Sun Jul 6 02:28:43 EDT 2008

What does the script look like?

BTW: Circular references alone cannot cause memory leak. CRL GC handles them right.


-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Aaron Clauson
Sent: Saturday, July 05, 2008 7:10 PM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Memory Leak with Certain Script Exceptions


I use the IronRuby scripting engine in a long running server process and
came across an issue where the memory utilisation of the process started
steadily rising in line with a memory leak. The server process is
written in C# (no unmanaged code) and I spent a lot of time double
checking and profiling the application to try ensure there were no
circular references or static lists keeping hold of objects etc.

Eventually I started looking at the Ruby script processing and found
that when a script threw certain exceptions the memory utilisation on
the process would start steadily incrementing. It's not all exceptions,
syntax errors and method missing execeptions seem fine but
ArgumentOutOfRange or NullReferenceExceptions exhibit the behaviour. A
stack trace of such a call is shown below.

I checked the behaviour using the latest version from svn (6 Jul 2008).

System.ArgumentOutOfRangeException: startIndex cannot be larger than
length of string.
Parameter name: startIndex
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32
length, Boolean fAlwaysCopy)
   at _stub_##44143(Closure , CallSite , CodeContext , Object , Int32 )
   at Microsoft.Scripting.Utils.InvokeHelper`6.Invoke(Object arg0,
Object arg1, Object arg2, Object arg3, Object arg4)
   at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object
instance, Object[] args)
context, CallSite`1 site, Object[] args)
site, CodeContext context, T0 arg0, T1 arg1)
   at Initialize##44129(Closure , CodeContext )
   at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean
   at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean
   at Microsoft.Scripting.ScriptCode.Run(Scope scope)
   at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink
   at Microsoft.Scripting.SourceUnit.Execute(Scope scope)
   at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code)


Posted via http://www.ruby-forum.com/.
Ironruby-core mailing list
Ironruby-core at rubyforge.org

More information about the Ironruby-core mailing list