Search code examples
delphimemorywsdlmemory-leaks

TXSDateTime/TXSDecimal memory leaks in web services in Delphi XE


I'm experiencing some challenges with memory management with a TRemotable descendant class that was created by the WSDL importer in Delphi XE.

The TRemotable descendant class is declared as follows:

Patient = class(TRemotable)
private
  ...
  FDOB: TXSDateTime;
  ...
  function  GetDOB: TXSDateTime;
  procedure SetDOB(const ATXSDateTime: TXSDateTime);
  ...
public
  destructor Destroy; override;
published
  ...
  property DOB: TXSDateTime  read GetDOB write SetDOB;
  ...
end;

...
implementation
...

destructor Patient.Destroy;
begin
  SysUtils.FreeAndNil(FDOB);
  inherited Destroy;
end;

...

function Patient.GetDOB: TXSDateTime;
begin
  Result := FDOB;
end;

procedure Patient.SetDOB(const ATXSDateTime: TXSDateTime);
begin
  FDOB := ATXSDateTime;
end;

One problem that I noticed is that when I create and use the TXSDateTime descendant DOB (or in another example, a TXSDecimal called 'Qty'), if I FreeAndNil(Qty) or FreeAndNil(DOB) the Patient class still attempts to FreeAndNil(TXSCustom_Descendant); I'll get 'Multi Free' exceptions from the EurekaLog Memory Leak detector. If I don't free the TXSxxx object but just free the Patient class - which calls FreeAndNil() on the object anyway, I get memory leaks.

I realize this sounds a bit vague, but I've worked a lot with Web Svcs, the WSDL Importer, and the various associated interfaces, and have never seen a problem like this.

TIA


Solution

  • I'll close this because I've found other issues that may be causing the leaks. Until I confirm, no sense in leaving this open.