The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Some FastMM scenarios require NeverUninstall because the System unit finalizes things innitialised in other units

Posted by jpluimers on 2018/01/09

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:

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.