Update: Changes to the introduction of VCL styles in XE2 fix memory leak. Therefore, I think it was unintentional.
I ran into a VCL memory leak today, at Themes.pas. This only happens for the DLL. The module completion code looks like this:
finalization if not IsLibrary then InternalServices.Free;
InternalServices is a singleton that is created on demand when you call ThemeServices . Many DLLs do not have a user interface and therefore never create this singleton. However, I happen to have a COM add-in in Excel that causes this leak to occur.
The leak doesnβt bother me much, because this DLL is never loaded or unloaded from the same process. And I know how I could fix the leak using the ThemeServicesClass global variable.
My question, however, is to ask if anyone can explain why this code is what it is. It seems to be deliberately encoded in this way. For life, I cannot come up with an explanation for this intentional leak.
David heffernan
source share