C# and .NET interview questions around JIT and NGEN.
What is JIT ( Just in time)?
IL code is a half compiled code during runtime this half compiled code is compiled in to full machine language. This compilation is done by JIT.
What are different types of JIT ?
Normal-JIT (Default): - This the methods needed during runtime and caches them.
Econo-JIT: - This compiles the methods needed during runtime but there is no caching.
Pre-JIT: - This compiles the complete source code into native code during build itself. No compilation happens during runtime , there is no activity from JIT during runtime. We can implement Pre-jit by using ngen.exe.
Explain NGEN.EXE ?
Ngen stores full compiled.NET native code in to cache. In other words rather than dynamically compiling the code on run time a full image of native compiled code is stored in cache while installing the application. This leads to better performance as the assembly loads and execute faster.
In order to install full compiled native code in cache we can execute the below command line from your visual studio command prompt.
Watch our latest video on C# interview questions & answers :-