This should reduce the executable size quite a bit in some of my very large projects. I am sure there would be other benefits too.
EDIT: Is there perhaps a utility that will scan the project and remove redundant ones automatically? I do have 100s of projects and "automatic remove" would be first prize although if I have to I will go the manual way with the help of identifying utilities.
You might want to take a look at at CnPack.
CnPack includes a Uses cleaner wizard wich hasn't failed me yet.
I used to use Icarus that gave me a report of unused uses entries.
From the web page
ICARUS parses Delphi or Borland Pascal source code and generates a Uses Report. This report will help you remove unneeded units from your uses lists. You will also know which units that can be moved from the interface uses list to the implementation uses list.
Removing unused uses references has multiple benefits: Cleaner code to maintain, no need to bother about code that is not used Code from initialization and finalization sections in unused units is not linked in Compilation runs smoother and quicker
ICARUS is very easy to use, just select a source file, set a few options, and start analyzing. Or let the built-in wizard guide you through this process.
ICARUS is FREEWARE.
Such a tool can never analyze if the initialization or finalization sections of a used unit need to be executed or not. Removing units from the uses could result in not running initialization and finalization sections and therefore result in bugs.
If your code can be compiled with Free Pascal, the Free Pascal compiler also will emit hints about unused units in your code.
See also this SO entry with additional information about possible problems, like RTTI based methods:
https://stackoverflow.com/questions/605977/tools-to-detect-dead-code-in-delphi2007-or-above/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With