Clever Geek Handbook
📜 ⬆️ ⬇️

Ngen

The Native Image Generator is a utility that allows you to create CLR images in native code from assemblies on the CIL code for the runtime environment and install it in the assembly cache of the local computer. Due to this, the efficiency of managed applications is increased: instead of the JIT compilation, the finished assembly is loaded on the native code.

Benefits:

  • Reduces application loading time since no JIT compilation is required.
  • reduces the time of the first launch of functions, since JIT compilation is not required.
  • improves memory usage, since a JIT compiler is not required.
  • received dlls can be used simultaneously by many processes. (sharing between processes)
  • compilation takes place for a specific processor used in the system.

Disadvantages:

  • Limitations on the use of the Assembly.LoadFrom method
  • Native image does not replace the original dll, but is stored separately. Therefore, more disk space is used.
  • Unsynchronized NGen files. When a new version of the assembly appears, you must update the image in the local cache.
  • Since the native image and the source assembly have different addresses for functions, when calling methods that are in the native image, the operation of modifying the base address is added.

Application:

  • If the dll uses many processes or it is used from different domains. Native image will enable the simultaneous use of the library by many processes.
  • If you need to speed up the launch of the application and reduce the memory used.
  • Application to large programs gives a greater effect than application to small programs.
  • For programs with a long runtime, the effect is very small (since JIT compilation is performed only once - on the first call. Next, the compiled version is used. And with each new call, the total difference will decrease.)

All .NET frameworks during installation create images in a native image.

Literature

  1. Bart De Smet. Native Image Generation // C # 4.0 Unleashed. - Pearson Education, 2011 .-- P. 115. - 1080 p. - ISBN 9780132681728 .
  2. Jeffrey Richter. The Native Code Generation Tool: NGen.exe // CLR via C #. - Pearson Education, 2012 .-- P. 35. - 894 p. - ISBN 9780735668768 .

Links

Native Image Generator at MSDN

See also

  • .NET Framework
Source - https://ru.wikipedia.org/w/index.php?title=Ngen&oldid=89351836


More articles:

  • Douglas, Archibald, 6th Earl of Angus
  • Feminized Hemp
  • Stewart, John, 3rd Earl of Lennox
  • World War I chemical warfare agents
  • Seletskoe Lake (Karelia)
  • 1900 Summer Olympics Tennis - Men's Doubles Tournament
  • Mgaloblishvili, Grigol Zurabovich
  • Isotopic composition of water
  • Octopuses
  • Iceliev, Leonid Izrailevich

All articles

Clever Geek | 2019