Closed cuiliang closed 3 years ago
Sample project MemoryTest.zip
Hello @cuiliang ,
Thank for reporting.
We will look at it to see if we missed something in the dispose
part.
If you don't want the current behavior, you can disable the cache:
_evalContext.UseCache = false;
Best Regards,
Jon
@JonathanMagnan Thank you! UseCache = false;
works.
Hello @cuiliang ,
After review, we find out that the cache is global by default. Which explain why object are not disposed.
However, you can use a local cache with the UseLocalCache
option:
var _evalContext = new EvalContext();
_evalContext.UseLocalCache = true;
When disposing, everything will be correctly disposed since the cache is local and not global.
It has been a long time, so I'm not exactly sure why we made the cache global by default, it might just because of backward compatibility reason.
Let me know if that answer correctly to the current issue.
Best Regards,
Jon
Thank you~
What's the cache used for? There seems no document about it.
The cache is used to faster execute a compiled expression.
So for example, if you can from time to time a method that execute always the same expression but with different parameter, this expression will be compiled only once. All subsequent execution will take the compiled code from the cache.
So for performance reason.
Code:
Compare between after first and thrid button click.