Hi,
Doing a simple stress test to see if the ScriptLibrary release scripts suffer leakage due to repetitive compilation. Doing the test freezes up VS 2013 to the point where you have to kill it using Task Manager. Nothing in the IDE responds to anything after trying to set a breakpoint while the test is running for a while. It seems to get incrementally slower also as the loop runs longer.
```
[TestMethod]
public void TestMethod1()
{
var b = new StringBuilder();
b.AppendLine("using System;");
b.AppendLine("public class Script {");
b.AppendLine(" public int Sum(int a, int b) {");
b.AppendLine(" return a+b;");
b.AppendLine(" }");
b.AppendLine("}");
for (int n = 0; n < 1000000000; n++)
{
dynamic script = CSScript.Evaluator.LoadCode(b.ToString());
int result = script.Sum(10, 20);
}
GC.Collect();
GC.WaitForFullGCComplete(10000);
Console.WriteLine("Done");
}
```
Comments: Just forgot to mention... CSScript.LoadMethod (as well as LoadCode and Load) will trigger recompiling if the change in the code to be compiled is detected. If the caching isn't what you are looking for you can diasable it with `CSSCript.CacheEnabled=false;` In the code sample for AsmHelper the loaded assembly is unloaded automatically when the execution passes the scope of the `using`: ```C# using (var helper = new AsmHelper(asmFile, null, true)) { //assembly loaded } //assembly unloaded ```
Doing a simple stress test to see if the ScriptLibrary release scripts suffer leakage due to repetitive compilation. Doing the test freezes up VS 2013 to the point where you have to kill it using Task Manager. Nothing in the IDE responds to anything after trying to set a breakpoint while the test is running for a while. It seems to get incrementally slower also as the loop runs longer.
```
[TestMethod]
public void TestMethod1()
{
var b = new StringBuilder();
b.AppendLine("using System;");
b.AppendLine("public class Script {");
b.AppendLine(" public int Sum(int a, int b) {");
b.AppendLine(" return a+b;");
b.AppendLine(" }");
b.AppendLine("}");
for (int n = 0; n < 1000000000; n++)
{
dynamic script = CSScript.Evaluator.LoadCode(b.ToString());
int result = script.Sum(10, 20);
}
GC.Collect();
GC.WaitForFullGCComplete(10000);
Console.WriteLine("Done");
}
```
Comments: Just forgot to mention... CSScript.LoadMethod (as well as LoadCode and Load) will trigger recompiling if the change in the code to be compiled is detected. If the caching isn't what you are looking for you can diasable it with `CSSCript.CacheEnabled=false;` In the code sample for AsmHelper the loaded assembly is unloaded automatically when the execution passes the scope of the `using`: ```C# using (var helper = new AsmHelper(asmFile, null, true)) { //assembly loaded } //assembly unloaded ```