Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What is Native Image Generator (Ngen.exe)
What is Native Image Generator (Ngen.exe)?
✍: Guest
The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on your assembly's
MSIL and generate native machine code which is cached to disk. After the image is created .NET
runtime will use the image to run the code rather than from the hard disk. Running Ngen.exe on
an assembly potentially allows the assembly to load and execute faster, because it restores code
and data structures from the native image cache rather than generating them dynamically.
Below are some points to be remembered for Native Image Generator:-
To run Ngen.exe, use the following command line.
ngen.exe install <assemblyname>
This will synchronously precompile the specified assembly and all of its dependencies. The generated
native images are stored in the native image cache.
In .NET Framework 2.0 there is a service (.NET Runtime Optimization Service) which can
precompile managed assemblies in the background. You can schedule your assemblies to be
precompiled asynchronously by queueing them up with the NGEN Service. Use the following
command line.
ngen.exe install <assemblyname> /queue:<priority>
Assemblies which are critical to your application's start up time should either be precompiled
synchronously or asynchronously with priority 1. Priority 1 and 2 assemblies are precompiled
aggressively while Priority 3 assemblies are only precompiled during machine idle-time.
Synchronously precompiling your critical assemblies guarantees that the native images will be
available prior to the first time your end user launches the application but increases the time taken
to run your application's set up program.
You can uninstall an assembly and its dependencies (if no other assemblies are dependent on
them) from the native image cache by running the following command.
ngen.exe uninstall <assemblyname>
Native images created using Ngen.exe cannot be deployed; instead they need to be created on the
end user's machine. These commands therefore need to be issued as part of the application's
setup program. Visual Studio .NET can be used to implement this behavior by defining custom
actions in a Microsoft Installer (MSI) package.
Note: - One of the things the interviewer will expect to be answered is what scenario will
use a Native Image generator. Best is to say that we first need to test the application
performance with Native Image and with out it and then make
2007-10-22, 8635👍, 0💬
Popular Posts:
Can static variables be declared in a header file? You can't declare a static variable without defin...
.NET INTERVIEW QUESTIONS - Is versioning applicable to private assemblies? Versioning concept is onl...
What's wrong with this initialization? char *p = malloc(10); My compiler is complaining about an ``i...
How To Select Some Rows from a Table? - MySQL FAQs - SQL SELECT Query Statements with GROUP BY If yo...
How does multi-threading take place on a computer with a single CPU? The operating system's task sch...