Hi
I use RO SDK
const
RO_VERSION = '9.5.111.1399';
We found two problems in TRORttiClientCache.GetCustomAttributes:
- memory leak
- non-threadsafe code
This is a proposed fix:
function TRORttiClientCache.GetCustomAttributes(aObject: TRttiObject): TDictionary<String, String>;
var
la : TArray<ROCustomAttribute>;
a: ROCustomAttribute;
begin
BeginRead;
try
if fCustomAttributes.TryGetValue(aObject, result) then
Exit;
BeginWrite;
try
if not fCustomAttributes.TryGetValue(aObject, result) then begin
Result := CreateDict<String>;
la := aObject.ROGetAttributes<ROCustomAttribute>;
for a in la do
Result.Add(LowerCase(a.Name), a.Value);
fCustomAttributes.Add(aObject, result); // <- fixing the leak
end;
finally
EndWrite;
end;
finally
EndRead;
end;
end;
regards