title: TXSDateTime/TXSDecimal memory leaks in web services in Delphi XE
body: <p>I'm experiencing some challenges with memory management with a TRemotable descendant class that was created by the WSDL importer in Delphi XE.</p>
  
  <p>The TRemotable descendant class is declared as follows:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>TIA</p>