I'm using the tool MapFileStats to inspect generated map files from delphi. I found that anonymous methods generate some kind of metadata, which doesn't seem to be related with RTTI. What kind of metadata is it? It would be nice to remove it because in our production environment it sums up to a very large size.
Example code:
program RttiDemo;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
{$RTTI EXPLICIT METHODS([]) FIELDS([]) PROPERTIES([])}
{$WEAKLINKRTTI OFF}
var
AProc: TProc;
begin
try
AProc := procedure()
begin
// ...
end;
except
on E: Exception do
WriteLn(E.ClassName, ': ', E.Message);
end;
end.
Screenshot from MapFileStats:
Another example:
program RttiDemo;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
{$RTTI EXPLICIT METHODS([]) FIELDS([]) PROPERTIES([])}
{$WEAKLINKRTTI OFF}
type
TDemo = class
procedure Demo();
end;
procedure TDemo.Demo;
var
AProc: TProc;
begin
AProc := procedure()
var
i: Integer;
begin
i := 5;
WriteLn(i);
end;
AProc();
end;
var
Demo: TDemo;
begin
Demo := TDemo.Create();
try
Demo.Demo;
finally
FreeAndNil(Demo);
end;
end.
Screenshot: