views:

306

answers:

4

Hello,

I am using the .NET 4.0 client profile for my app and I run a dual core with 4 GB Ram and a fast hard disk.

nothing big is done at the start just showing a generic List in a wpf listview.

How can I make the cold start faster of my assembly ?

I have done now again a cold start and run the windowsapplication.exe in my \obj\x86\Debug folder and my harddisk run like hell and it took 10,5 seconds ???

What is wrong?

The warm start after the cold one took 1 second.

Java 6 apps has not that problem, not at all just to compare...

UPDATE:

I remove all methods which read data when my ViewModels are created.

Still 10 seconds to show up. Its not a problem of reading data from RAM. The problem is the heavily busy harddisk which has never been that loud except running a .net 4.0 wpf app...

I do not reference any 3rd party dll`s.

These are the assemblies I reference:

Microsoft.CSharp Presentation.Core PresentationFramework System System.Core System.Data System.Xaml System.Xml System.Xml.Ling WindowsBase

UPDATE 2:

I created now a .NET 4.0 wpf project from scratch with just a empty window and green background;-)

The cold start took 3 seconds (Hard disk got very busy)

then I run my other wpf app which took earlier 10 seconds. Now it needs only 1,5 seconds to show up on screen.

The situation is now clear to me:

My application as nothing what could make it slow. Its just about the FIRST wpf app loaded or not.

I think I will do it like ADOBE Reader. Put a application accelerator... in the autostart being a small hello world wpf app...

+3  A: 

You can use ngen to pre-compile your assemblies. That should help.

Edit: There may be one thing that can help. If this is a wpf application based on the "new wpf application" template in visual studio, your application will reference a bunch of assemblies that you may not use. Try to remove all unused assemblies from your applications references and see if that helps.

Rune Grimstad
It might, although I believe that some or all of the JIT code gets cached on the first execution.
Robert Harvey
It should, but the question is on how to make the cold start (ie. first time the app is run) faster. As long as the app doesn't do much at start up, I don't think there is anything other than ngen that will help.
Rune Grimstad
Ngen on a small app makes the cold start slower. Bigger DLL to load.
Hans Passant
+1  A: 

Thats not normal, do you make connections to a database or to some network? Waiting for some OS resource?

Henri
+1  A: 

.Net apps start slowly compared to natively compiled apps, but that sounds excessive. Procmon may offer some insight into what it is waiting for.

ScottS
+1  A: 

You might want to take a look at this MSDN blog post by Jossef Goldberg.

matthew.perron