Memory leak in uRoRTTIServerSupport FindAllROTypes in 1543

I get an memory leak from FastMM after shutdown on version 1543.
I don’t understand why, but it is the comparer used to sort the result array that causes it. By declaring the it as a local variable with explicit interface type (IComparer), it works. This must be a Delphi issue as the comparer parameter of TArray.Sort is declared as an interface, and the compiler should have inferred the type as an interface and not a class instance.
This is on Delphi 11.1.

This is how I have solved it for now:
var vComparer:IComparer := TDelegatedComparer.Create(
function(const Left, Right: TRTTIType): Integer
begin
Result := AnsiCompareText(Left.Name, Right.Name)
end);
TArray.Sort(Result,vComparer);

Logged as bugs://D19271.

bugs://D19271 was closed as fixed.

Hi

can you post here the patch? Thank you very much!

Hi,

you can apply patch from the 1st post


  l_comparer: IComparer<TRTTIType>;
...
    l_comparer := TDelegatedComparer<TRTTIType>.Create(
      function(const Left, Right: TRTTIType): Integer
      begin
        Result := AnsiCompareText(Left.Name, Right.Name)
      end
      );
    TArray.Sort<TRTTIType>(Result, l_comparer);
    l_comparer := nil;
2 Likes