Skip to content

Possible memory leak? #14

@sp00x

Description

@sp00x

It was not entirely clear to me that the process of doing .Source = '..'; and .Run() several times was just appending to the source code, like a REPL, but anyways it's cool that it works like this. However, re-defining variables or functions seem to lead to memory leaks, and I'm not sure if this is intended or part of the ECMA script or not, i.e. the following will log "A2" twice, both in Node.js and RO Script:

 function A() { console.log("A1") }; A(); function A() { console.log("A2") }; A();

So, a short example:

EcmaScriptComponent script = new RemObjects.Script.EcmaScriptComponent();

// imagine there is a console.log()

script.Source = @"function A() { console.log(""A1"") }; A(); function A() { console.log(""A2"") }; A();";
script.Run(); // logs A2 twice

script.Source = @"function B() { console.log(""B1"") }; B();";
script.Run(); // logs B1

script.Source = @"function B() { console.log(""B2"") }; B();";
script.Run(); // logs B2

script.Source = @"function B() { console.log(""B3"") }; B();";
script.Run(); // logs B3

script.Source = "var foo = 'bar';";
script.Run();

script.Source = "var foo = ''; console.log('foo is: ' + foo)"; // logs bar as expected, unless we call script.Clear() in which case "var is unexpected"-borks.
script.Run();

while (true)
{
    //script.Source = "var foo = 'bar';"; // leaks a bit
    script.Source = "function A() {}"; // leaks a lot
    script.Run();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions