Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak? #14

Open
sp00x opened this issue Feb 9, 2017 · 0 comments
Open

Possible memory leak? #14

sp00x opened this issue Feb 9, 2017 · 0 comments

Comments

@sp00x
Copy link

sp00x commented Feb 9, 2017

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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant