Precompiled Code

A

A

Hi,

I understand that the ASP.Net environment compiles code for a page on its
first access and then serves pages from that precompiled code for subsequent
requests. I have a couple of questions:

1. Does this precompiled code ever expire? If so, when?

2. Does each and every page have to go through this process or does the
compiler compile all pages in the directory so that it doesn't have to do
them one at a time for each request?

Thanks
 
C

Chris Jackson

There are two steps to compilation: compiling to MSIL, and compiling to
native code. The first time you hit a page, an assembly is dynamically
generated and compiled. This dll is then persisted to disk. Until you drop a
new aspx page onto your server, this compiled MSIL will be sitting on your
hard drive. (This check is performed with each visit.)

This MSIL must then be JIT compiled to native code. The code that is JIT
compiled will still be resident in memory until you stop the process that
this native code exists in. Note that you will only JIT compile the code
that you actually need to execute, so not all of your code may be compiled
to native code for every request.

The compilation model is always on an as-needed basis: code is compiled when
it is needed. A branch that doesn't execute is never JITted. A page that is
never viewed is never compiled.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top