How to increase the startup speed of the delphi app?

前端 未结 11 2005
醉梦人生
醉梦人生 2020-12-24 09:54

What do you do to increase startup speed (or to decrease startup time) of your Delphi app?

Other than application specific, is there a standard trick that always wor

11条回答
  •  既然无缘
    2020-12-24 10:45

    Three things happen before your form is shown:

    1. All 'initialization' blocks in all units are executed in "first seen" order.
    2. All auto-created forms are created (loaded from DFM files and their OnCreate handler is called)
    3. You main form is displayed (OnShow and OnActivate are called).

    As other have pointed out, you should auto-create only small number of forms (especially if they are complicated forms with lots of component) and should not put lengthy processing in OnCreate events of those forms. If, by chance, your main form is very complicated, you should redesign it. One possibility is to split main form into multiple frames which are loaded on demand.

    It's also possible that one of the initialization blocks is taking some time to execute. To verify, put a breakpoint on the first line of your program (main 'begin..end' block in the .dpr file) and start the program. All initialization block will be executed and then the breakpoint will stop the execution.

    In a similar way you can step (F8) over the main program - you'll see how long it takes for each auto-created form to be created.

提交回复
热议问题