Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Very simple app - apparent memory leak

0
0
Hi - I'm sure I'm doing something wrong here, as there is no way this kind of issue could slip through your tests...

I added clearscript to a complex application I develop, and had major memory problems, so have stripped it down to the simplest reproduction of the issue that I can.

It seems like some internal clearscript instances of c# runtime objects aren't being garbage collected.

Running .NET Memory Profiler by SciTech produces the following chart

Image

The chart is produced by the following code (just a timer on a form with a 1000ms interval)
     private void timer1_Tick(object sender, EventArgs e)
    {
        JScriptEngine aEngine = null;
        try
        {
            aEngine = new Microsoft.ClearScript.Windows.JScriptEngine();
            aEngine.AddHostType("Console", typeof(Console));
            aEngine.Execute(@"Console.WriteLine(""Hello"");");
        }
        catch (System.Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
            aEngine.Dispose();
        }
    }
You can see when garbage collection happens, and half of the instances and half of the memory isn't cleaned up. The sawtooth pattern you see there will just keep going and going and going until the PC shuts down.

I am using the JScript engine as you can see, I cannot install V8 in the environment where the application will be deployed.

please help
thanks,
Simon

Viewing all articles
Browse latest Browse all 2297