Question

Its very basic question.

JIT compilation is on demand as per MSDN MSIL To Native Code. Every time when we run the assembly JIT compiler converts MSIL to Native language? Or When we run assembly first time, it converts and store the native language code to somewhere?

Thanks in advance!

Was it helpful?

Solution

The JIT compiler compiles your code when you start the application and stores it in memory.

This code can be cached by ngen.exe (Native Image Generator) and stored in the native image cache. This will be automatically loaded the next time you start the application, and you won't have to JIT the MSIL code a second time.

Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead of using the just-in-time (JIT) compiler to compile the original assembly.

The native image cache can be found on a path similar to C:\Windows\assembly\NativeImages_v4.0.30319_64. This path is not accessible through Windows Explorer, so use cmd or a powershell.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top