How to reduce the size of a Delphi DLL?

I recently migrated from Delphi 7 to Delphi XE3.

The DLL file, which was 107kb in Delphi 7, is now 2.7 MB. The other, which was 114kb, is now 4.7 MB!

This is normal? What can I do to reduce file sizes? If you need more information, please ask.

UPDATE:

Both dll files have already compiled in release mode.

Following Mason's advice:

The 4.7MB file was reduced to 834kb, and the 2.7MB file was reduced to 2.1MB. The 2.1MB file uses Generics and an external library called nExcel, used to generate Excel files. While nExcel was also used when the file size was smaller, the use of Generics is a new addition to the code, and I think this may be the reason that the file size remains quite large.

+7
source share
1 answer

Some of them are inevitable; RTL has grown with the addition of additional features. However, much of this increase in size will be associated with the addition of extended RTTI in Delphi 2010.

You can fix this by placing the following two lines in the main project file, before any uses :

 {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} {$WEAKLINKRTTI ON} 

This will force the compiler to minimize the extended RTTI throughout the project. (Remember that this means you wonโ€™t have RTTI functionality available. But since this is a Delphi 7 project, you probably arenโ€™t using it yet. You will need to read the extended RTTI and see if you can find useful things related to this. )

+15
source

All Articles