anchor.diff:  end;
   
   
  -procedure TKMSavedReplays.SaveToFile(const aFileName: UnicodeString);
  -var
  -  S, S2: TKMemoryStreamBinary;
  +procedure DoCompressedSaveAndFree(const aFileName: UnicodeString; S: TKMemoryStreamBinary);
  +var
  +  S2: TKMemoryStreamBinary;
     CS: TCompressionStream;
   begin
  -  S := TKMemoryStreamBinary.Create;
  +  S2 := TKMemoryStreamBinary.Create;
     try
  -    Save(S);
  -
  -    S2 := TKMemoryStreamBinary.Create;
       S2.PlaceMarker('SavedReplaysCompressed');
   
       CS := TCompressionStream.Create(cldefault, S2);
  
positive.code: 
  implementation
  uses
    SysUtils
    {$IFDEF FPC}, zstream {$ENDIF}
    {$IFDEF WDC}, ZLib {$ENDIF};
  
  
  { TKMSavedReplays }
  
negative.code:     CS.Free;
  
      S2.SaveToFile(aFileName);
    finally
      S.Free;
      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;
  
  
  