Reputation: 2875
How do I guarantee that the CLR's JIT "method" cache has been cleared? Is it simply a matter of starting a new instance of the application, or do you have to re-boot the PC?
It is my understanding the the CLR JIT is process specific, and that this should work.
Foobar.exe
is started.DoWork()
is invoked for the first time
DoWork()
) to machine codeDoWork()
is called again, and existing machine code is used. (i.e. JIT is bypassed)Foobar.exe
application.
Foobar.exe
runningFoobar.exe
is started again.DoWork()
is invoked for the first time
DoWork()
) to machine codeDoWork()
is called again, and existing machine code is used. (i.e. JIT is bypassed)Any feedback that can be provided would be greatly appreciated.
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
Upvotes: 1
Views: 360
Reputation: 68
Your understanding is very correct.
Every time the process is started, the JIT emits a new machine code that is used until the process is finished.
However, it's also possible to create a machine code cache, to avoid repetitive jit emission. It's know as NGen
Upvotes: 1