Hello querdenker,
It doesn't look like you're doing anything wrong. Can you say any more about the sort of work your scripts are doing?
Some general suggestions:
It doesn't look like you're doing anything wrong. Can you say any more about the sort of work your scripts are doing?
Some general suggestions:
- Make sure you're using the latest version of ClearScript. A number of memory leaks have been fixed since the last point release.
- Is it possible that your scripts are generating increasing amounts of data that is reachable from the global/root object?
- Try to avoid script compilation as much as possible. Consider using compiled scripts or direct invocation of script functions to re-execute script code.
- We've found that when it comes to garbage collection, V8 is lazy to an extent that can get it in trouble. Consider invoking the garbage collector explicitly via
ScriptEngine.CollectGarbage(true)
. Use a schedule that makes sense for your application - periodically or based on idle state, maximum invocation count, etc. -
If all else fails, consider disposing the script engine and spinning up a fresh instance once in a while - again, using a schedule that makes sense for you.