lag time reading new code?

  • Thread starter Thread starter Sam Marrocco
  • Start date Start date
S

Sam Marrocco

I've noticed that the first time code is called, it seemed to take a
noticably longer amount of time. Is this because the code isn't loaded
until the first time it is needed? If so, is there a way to force
modules or classes to be read at startup to avoid the lag later when
they are first needed?
 
Methods are indeed compiled from MSIL the first time they are called -
this is why it is named a "just-in-time" compiler. It is also possible
to use the ngen.exe tool to precompile your MSIL into native code. This
may reduce execution time, although you lose out on optimizations that
may only be possible when the runtime condition is known. This may or
may not be significant - I would recommend you profile applications
before and after using the ngen tool on them and see how it goes.

There are usually ways to ngen code during the installation process on
a user's machine - if you wish to do this, check your setup
documentation for this feature.
 
there is a cofiguration option in 2.0 that address this at install time
and allows you to specify native image generation then (i.e. during the
install)

<assembly:NGen(NGenHint.Eager)>
 

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

Back
Top