You always have to be careful with Delphi finalization
sections cleaning up things that might have not created inside the corresponding initialization
section. This is especially true for the System
unit.
That one actually contains this little piece of code that is being called after FinalizeUnits
is called which also fianalises external memory managers like FastMM:
finalization {$IFDEF WEAKREF} InstHashMap.Finalize; {$ENDIF}...{$IFDEF MSWINDOWS} FinalizeLocaleDate; if PreferredLanguagesOverride <> nil then FreeMem(PreferredLanguagesOverride);...
Which means that you will have to enable the NeverUninstall
conditional define as soon as the InstHashMap
has been used.
Most often that’s the case with FMX applications that heavily relies on weak references.
The same holds for PreferredLanguagesOverride
which is used by SetLocaleOverride and can be worked around by performing this right at the end of the .dpr:
SetLocaleOverride('');
–jeroen
via: