anchor.diff:      CS.Free;
   
       S2.SaveToFile(aFileName);
  -    S2.Free;
     finally
       S.Free;
  -  end;
  +    S2.Free;
  +  end;
  +end;
  +
  +
  +procedure TKMSavedReplays.SaveToFile(const aFileName: UnicodeString);
  +var
  +  S: TKMemoryStreamBinary;
  +begin
  +  S := TKMemoryStreamBinary.Create;
  +  Save(S);
  +
  +  {$IFDEF WDC}
  +    TTask.Run(procedure
  +    begin
  +      {$IFDEF DEBUG}
  +      TThread.NameThreadForDebugging('TKMSavedReplays.SaveToFile');
  +      {$ENDIF}
  +      DoCompressedSaveAndFree(aFileName, S);
  +    end);
  +  {$ELSE}
  +    DoCompressedSaveAndFree(aFileName, S);
  +  {$ENDIF}
  +
  +  //S is freed in DoCompressedSaveAndFree
   end;
   
   
  
positive.code: 
  implementation
  uses
    SysUtils
    {$IFDEF FPC}, zstream {$ENDIF}
    {$IFDEF WDC}, ZLib {$ENDIF};
  
  
  { TKMSavedReplays }
  
negative.code: end;
  
  
  procedure DoCompressedSaveAndFree(const aFileName: UnicodeString; S: TKMemoryStreamBinary);
  var
    S2: TKMemoryStreamBinary;
    CS: TCompressionStream;
  begin
    S2 := TKMemoryStreamBinary.Create;
    try
      S2.PlaceMarker('SavedReplaysCompressed');
  
      CS := TCompressionStream.Create(cldefault, S2);
  