Optimizing application starup

Uncle Remus

New member
Joined
Jun 27, 2007
Messages
2
Programming Experience
10+
Does anyone have any good tips on optimizing the startup time of an application (vb.net 2005 of course). Unfortunately I am saddled with a PII-800 with 256MB of RAM. This is not my box so I can't upgrade it... I just have to write code for it. Currently my startup form uses the following references/Imports:

System
System.Windows.Forms
System.Drawing
System.Diagnostics
System.Xml
System.Reflection
System.Net.Sockets
System.IO
System.Threading

Not really doing anything special on this form in the load or shown events but the first time started it takes at least 40 seconds to come up. Before anyone suggests using a splash screen I would rather focus on speeding the start time of this form first as a 40 second splash is still unnacceptable. After the first start this time is reduced to about 20 seconds so some caching is taking place. But, I'm still stuck with the 40 seconds for the first start. I realize that it may be difficult for anyone to offer suggestions without first seeing my code but I thought I'd ask if anyone had any "best practice" tips that I could start with. Anyone else out there stuck coding for a dog like this? lol. Any help would be greatly appreciated!
 
When you say "Not really doing anything special on this form in the load or shown events", what does that mean exactly? There is not much special about anything so to speak, but things tend to take time no matter how trivial. If you meant that is how long it takes to load an empty form with no controls and no code, then it comes as little surprise to hear exactly how slow a 3-4 generations old PC is compared with todays. But applications didn't take that much time to start "back then" and .Net is only marginally slower at startup because of the JIT, so there must be something going on after all.

As for general optimizations not much need to happen in Load event, it could probably wait until Shown, also there you could maybe start threading if there really was anything time consuming.
 
John, Thanks for your response. I am loading a couple of small XML files in form load but they make no noticeable difference when taken out. I have moved any real work into a timer that fires a few seconds after the shown event and that seems to help a little but not much. The only other thing happening in form laod is changing the background color of the labels/panels and such. But removeall of that doesn't make a diff either. The problem is with the form coming up initially. The form has a couple of panels, a half dozen labels and a half dozen small jpg's (10x10 pxl). Essentially the same controls on a VB6 form load on that dog assed machine in a couple / three seconds. Does it really take that long for the .net framework to spin up the objects that this app needs? 40 seconds is rediculous for this simple of a form even given the dog that its made to run on. Even a blank form that does nothing and only has a label on it takes 5 seconds to bring up. Again, are all the .net objects loading what is killing me here? If so, can anything be done to preload or pre cache these with a service or something. Really grasping here but any suggestions may help.

Of course my dev machine is a duo core 6400 with 2GB and it takes 3-4 seconds there. Makes it real difficult to troubleshoot for whats taking so long. The target machine is also a win2000 box.
 
Also helpful for finding time bottlenecks it to use StopWatch class to measure specific method calls or blocks of code. Some calls may take longer or shorter than you expect, and specific code accessing subsystems may react differenly with different hardware or in different networks for example.

3-4 seconds with what you describe on the CoreDuo sounds like an awful long time, too. Nothing like anything I've seen with several slower machines.

To skip the regular JIT compile startup you can precompile this part and install to Native Image Cache with Ngen.exe tool included with Framework. (though I've never used this myself, .Net never felt slow to need this here)
 
Back
Top