Friday, April 10, 2009

Improve the loading speed of Delphi application built with runtime package

When we use SysUtils.LoadPackage in Delphi, the following procedure will be invoked:


procedure InitializePackage(Module: HMODULE; AValidatePackage: TValidatePackageProc);
type
TPackageLoad = procedure;
var
PackageLoad: TPackageLoad;
begin
CheckForDuplicateUnits(Module, AValidatePackage);
@PackageLoad := GetProcAddress(Module, 'Initialize'); //Do not localize
if Assigned(PackageLoad) then
PackageLoad
else
raise EPackageError.CreateFmt(sInvalidPackageFile, [GetModuleName(Module)]);
end;


If we are very sure that our .bpl packages has no duplicate unit name, we may safely ignore the call to "CheckForDuplicateUnits" procedure. It should improve the loading speed of your Delphi application that built with runtime packages.

No comments: