Jump to content

Native Image Generator

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sundström (talk | contribs) at 11:40, 8 January 2010 (Created page with 'The '''Native Image Generator''', or simply '''NGEN''', produces a native binary image for the current environment (i.e; operating systems). This eliminates the JIT...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The Native Image Generator, or simply NGEN, produces a native binary image for the current environment (i.e; operating systems). This eliminates the JIT overhead at the expense of portability; whenever an NGEN-generated image is run in an incompatible environment, .NET framework automatically reverts to using JIT. Once NGEN is run against an assembly, the resulting native image is placed into the Native Image Cache for use by all other .NET assemblies. This makes it possible, for example, to use NGEN to process .NET assemblies at installation time, saving processor time later on, when the end-user invokes the application on their system.

NGEN is intended to make the assembly execute faster by removing the JIT compilation process at runtime, but this does not always improve performance because some optimizations can be done only by a JIT compiler (e.g., if the JIT compiler knows that the code is already running with full trust, it can skip certain expensive security checks). Because of this fact, it makes sense to use NGEN only after benchmarking the application performance before and after it.