Hi!
I have two C# assemblies (dll) and one desktop testprogram (also C#) and
when I start my testprogram and press the button that will use methods in my
two assemblies it goes really slow the first time. I thought this had to do
with the JIT. The strange thing is that if I start my testapp and press the
button once it goes slow. If I press the button once again it goes pretty
fast but if I let the application stand for an hour or so and then press
the button it will once again be slow. I thought that once the assembly is
JIT:ed it will be cached at least until my testprogram quits?
My assemblies are not put in the GAC since the assemblies are not shared by
other programs. However I tryed to put the assemblies in the GAC using
gacutil and used Ngen to create a native image. This did not improve any
performance for me.
Can someone shed some light why it goes slow? Is there anything I can do to
prevent this (I thought Ngen was the solution but it does not seem to
improve performance for me). My real application is actually a Win32 Delphi
app that will call my assemblies using com interop but I have the same
problems in my C# testprogram as well. I was thinking of starting a thread
in my win32 program that in the background will "warm up" my assemblies (is
Assembly.load a working way to precompile an entire assembly? I guess that
is not possible to use directly from a win32 application so I guess I will
have to wrap that into another assembly and use com to launch this assembly
that in turn will use Assembly.load on my other two assemblies?).
I'm using .NET Framework v1.1.4322.
Regards
/Hans
Tasos Vogiatzoglou - 19 May 2006 11:31 GMT
Ngen wont give you a performance benefit most of the times.
I assume that the initial delay is the time taken from the referenced
assemblies to load.
If the delay is unacceptable you can make your components
ServicedComponents and rely on pooling and JIT services.
Regards,
Tasos