Groups | Blog | Home
all groups > dotnet clr > october 2004 >

dotnet clr : Is the cached code is stored on permanent storage for future use



Hitesh
10/25/2004 7:43:03 AM
Hi,
I have a big confusion with me that if we have a windows application
executable built using C#.NET and when we execute it for the first time the
following things happens:
1. clr calls JIT to convert MSIL to native.
2. native code is cached and when next time same code comes into picture
during execution it gets loaded from the cache instead of getting JITed again.

Now my question is:
1. Is that cached code is there as long as the executable is up and running
or it will be there for always so that when you shuts down your system for
today and then come tommorow and boots up your system fresh and tries to
execute the same executable, then what happens?

Is the cached code is used that was cached yesterday?
or the same process of JITing and caching takes place again

--
Thanks
Hitesh
10/25/2004 9:21:05 AM
Hi Mattias,

Thanks for your answer now i am more comfortable with .NET than earlier.

Thanks and Regards
Hitesh Jain

[quoted text, click to view]
Richard Blewett [DevelopMentor]
10/25/2004 9:25:14 AM
By default, the IL is JIT'd every time the process is run (it is only cached in memory). There is a tool called NGEN.EXE which will compile the code on the deployed machine and cache the image in an area of the GAC called the native cache. However, not all types of applications benefit from being NGEN'd so it is best to test you particular application.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

Hi,
I have a big confusion with me that if we have a windows application
executable built using C#.NET and when we execute it for the first time the
following things happens:
1. clr calls JIT to convert MSIL to native.
2. native code is cached and when next time same code comes into picture
during execution it gets loaded from the cache instead of getting JITed again.

Now my question is:
1. Is that cached code is there as long as the executable is up and running
or it will be there for always so that when you shuts down your system for
today and then come tommorow and boots up your system fresh and tries to
execute the same executable, then what happens?

Is the cached code is used that was cached yesterday?
or the same process of JITing and caching takes place again

--
Thanks
Hitesh
Mattias Sjögren
10/25/2004 5:59:43 PM
[quoted text, click to view]

The native code is only stored in memory, and it's lost when the
process terminates. The code will be re-jitted every time you execute
the application.

If you want to store native code on disk you should look into the
Ngen.exe tool.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
AddThis Social Bookmark Button