2

My application has several large forms with lots of images which dramatically increases the size of the built executable. Over time, it seems that the startup performance becomes sluggish and it doesn't seem to be getting any better.

If I put all of the forms besides the main form in a separate dll, would it alleviate some of the pressure put on the application during startup?

I'd test it myself, but I have A LOT of forms and I don't want to do it unless someone can confirm that such an action will prove to be useful.

Eaton
  • 1,310
  • 2
  • 15
  • 31

5 Answers5

1

I'm not quite sure about that, but if I were you I would use the Profiler when it comes to improving performance.
Before I go guessing what's wrong, I consult with it and work my way up, because it tells me which methods and classes are costing the most in my code.

BeemerGuy
  • 8,139
  • 2
  • 35
  • 46
  • I've used that before, but most of the intense methods are called in 3rd party dlls I use and not in my code. And I don't have access to the source of those. )-: – Eaton Dec 16 '10 at 03:12
1

Many factors can affect startup performance. Have you used any tools to prove that it's the images?

For a start, go through these tips: http://devcomponents.com/blog/?p=361

And consider using multithreading to load bigger objects in the background.

SteveCav
  • 6,649
  • 1
  • 50
  • 52
  • Thanks for that link, very useful! I haven't really used any tools, but I think it is just the app loading all of them into memory that is bogging it down. And I have threaded all of the functions I do on startup. It helps, but not noticeably. – Eaton Dec 16 '10 at 03:12
  • Marked as answer - very helpful link. – Eaton Dec 17 '10 at 23:49
1

Another tip that may be useful: This reduced my application's startup time from 2 minutes to <10 seconds on a low-end thin client. Use NGEN to generate a precompiled native image of your assemblies.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • Yes, that will work for any completely managed assembly. It should also work on mixed-mode assemblies, but I've never tried. – Dark Falcon Dec 16 '10 at 03:30
0

I'm wondering if you were to use MEF and Lazy load, then when you actually need the module (Form) instantiate by calling .Value.

There are a couple of things I do with applications containing a lot of forms:

  • Create a UI .exe: basically only my forms
  • Create a backend .dll: everything that does the work behind the UI.

Are the images actually included in the .dll? If so, I would actually put my images into a .dll separate from the UI.

Given that the images are for toolbars, I wouldn't split them out as resources. I'll still stand fast on my advice to split into multiple .dlls.

IAbstract
  • 19,551
  • 15
  • 98
  • 146
  • By images I really mean toolbar images and such. Not actual images I put into Resources. Putting them all in a dll and linking them to the appropriate item on startup would take forever and may decrease performance even more. It's much easier to just link them via the Image property. (-: – Eaton Dec 16 '10 at 03:16
  • All in all, I would still think that MEF could actually help loading. – IAbstract Dec 16 '10 at 04:10
0

As others said, profile, don't guess.

Not just any profiler will do. Here's a user (besides me) who discovered random pausing on his own. You say the "intense" methods are all in dlls you don't have source code for - that's typical and normal. What you need to know is which statements in your code are requesting the time to be spent, and they can't be restricted to CPU-only time. Most profilers don't tell you this, but random-pausing does.

If you're interested, here's a recent discussion of the issues.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135