I'm using X-SuperObject to mashalize/unmarshalize object. X-SuperOject does have a class helper "FromJSON" that allows you to instantiate an object from an JSON string.
I'm using X-SuperObject to mashalize/unmarshalize object. X-SuperOject does have a class helper "FromJSON" that allows you to instantiate an object from an JSON string.
My problem is that I have a memory leeak when doing so :
var
Cust: TCustomer;
Begin
Cust := TCustomer.create;
Cust.Id := 6;
Cust := TCustomer.FromJSON(Cust.Get); //Cust.Get is connecting to a websercice, using it's id to fetch relevant data
Cust.free;
End;
In this case, Cust is created twice (initial creation, and TCustomer.FromJSON) but freed once.
Is there a way to solves this and keep my code clean (I don't want to decalre temporary variables that I'll free later) ?
My problem is that I have a memory leeak when doing so :
var
Cust: TCustomer;
Begin
Cust := TCustomer.create;
Cust.Id := 6;
Cust := TCustomer.FromJSON(Cust.Get); //Cust.Get is connecting to a websercice, using it's id to fetch relevant data
Cust.free;
End;
In this case, Cust is created twice (initial creation, and TCustomer.FromJSON) but freed once.
Is there a way to solves this and keep my code clean (I don't want to decalre temporary variables that I'll free later) ?
Comments
Post a Comment