Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A 110 kb .NET 4.0 app needs 10 seconds for a cold start, thats not acceptable !

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...

like image 872
msfanboy Avatar asked May 19 '10 21:05

msfanboy


2 Answers

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.

like image 144
Rune Grimstad Avatar answered Oct 02 '22 14:10

Rune Grimstad


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

like image 21
Matthew Perron Avatar answered Oct 02 '22 15:10

Matthew Perron