You are not logged in.
A memory leak is occurring when doing the following.
TResultsRun = class(TCollectionItem)
private
fTDC : TTestDataCollection;
protected
function GetNewerTestData:TTestDataCollection;
procedure SetNewerTestData(aValue:TTestDataCollection);
public
constructor Create(ACollection: TCollection); override;
destructor Destroy;override;
published
//property NewerTestData : TTestDataCollection read fTDC write fTDC; <----- all ok !!
property NewerTestData : TTestDataCollection read GetNewerTestData write SetNewerTestData; <----- memory leak
end;
(the getter and setter are simple assignments)
Are getters and setters supported for collections ?
Offline
Yes I guess. This occurs in an interface based client-server setting.
Offline
You have to write the setter correctly, as such:
procedure TCollTst.SetColl(const Value: TCollTests);
begin
fColl.Free;
fColl := Value;
end;
This comes from test.core.data.pas regression tests.
Offline
Thanks Ab ! Solves.
If I may hack this thread for another TCollection question.
In my applications, I use TCollections a lot. They might contain a lot of data. And this data is stored as JSON in the database for external use by non-mORMot applications.
All very well.
However, I would like to consider these TCollection fields as a kind of blobs, due to their huge data-size. So, I want to exclude them when retrieving data from the database.
Code for that (please excuse me for a bit long code listing):
rA := Rtti.RegisterClass(TOrmProduct);
pa := pointer(rA.Props.List);
count:=rA.Props.Count;
SQL:='';
repeat
if pa^.Value.ValueRtlClass=vcCollection then
begin
if pa^.Value.ValueClass.ClassParent=TDataRunCollection then SQL:=SQL+','+pa^.Name;
end;
inc(pa);
dec(count);
until count = 0;
Delete(SQL,1,1);
Fields:=TOrmProduct.OrmProps.FieldBitsFromExcludingCsv(SQL);
Question. Or feature request.
Would it be possible to implement something like this ?
Fields:=TOrmProduct.OrmProps.FieldBitsFromExcludingFromDataType(TDataRunCollection);
Fields:=TOrmProduct.OrmProps.FieldBitsFromExcludingFromClassParent(TDataRunCollection);
Offline
Offline
Works perfect. Thanks !!
Fields:=TOrmProduct.OrmProps.FieldBitsFromExcludingClass([TDataRunCollection],ooSelect,True);
Offline