Home > front end >  What's the impact of non-used units? Will it make the output exe larger?
What's the impact of non-used units? Will it make the output exe larger?

Time:03-23

I did some test with non-used units. There is no clear exe size difference by my testing. But I can't find any information in the document. My question is, will non-used unit uses increase the output file size?

CodePudding user response:

When you add some unused units into “uses part” of your code it’s not good practice, but it’s increase size of final exe-file by itself. Compiler analyze whole code and cutoff all unused parts, so it’s increase compilation time. But you need to remember one tricky things – non-uses units can contain code-parts that can be used not in a direct way. It can be “initialization part” of unit or some “Class constructors” that can be triggered automatically, so compiler will include it(and all chain of used types/units) into your exe-file. One more thing – when you compile some bpl-file – compiler optimization does not work in the same way, because it can not know what you will use from this bpl in future projects which will use this bpl.

  • Related