Correct ClearScript Cleanup

Jul 10 at 3:55 PM
I have been using ClearScript in a Project for a while and have been using a simple cleanup operation of "engine.Dispose(); engine = null;"
Looking at your included "ClearScriptConsole" I notice you have a "using { }" and that is all.

So my question is what is the correct method to ensure all resources are Cleaned Up so that if I create the ClearScript engine several times I am not consuming resources.

My question stems from the assumption that I am doing something wrong as each iteration of the ClearScript engine that I execute results in a different value
eg 5 different calls of my "using { }" version of calling engine.Execute resulted in this below and I got the same using Dispose and also when adding GarbageCleanup(true).

Engine Name : V8ScriptEngine
Engine Name : V8ScriptEngine [2]
Engine Name : V8ScriptEngine [3]
Engine Name : V8ScriptEngine [4]
Engine Name : V8ScriptEngine [5]
Jul 10 at 4:46 PM
Hi egooner,

Calling the Dispose() method - either directly or via the using statement - is sufficient. If you don't do that, .NET's garbage collector will eventually take care of it, but it may take a long time.

As for engine names, "V8ScriptEngine [5]" refers to the fifth engine you've constructed with the name "V8ScriptEngine" during the current process's lifetime. It doesn't mean that there are five script engines currently active.

Jul 11 at 1:22 AM
Thanks for the feedback. I had hoped this was the case but was concerned that there is clearly tracking of the different instances having been created between NEW Engines telling me something was still around.