trichview.com

trichview.support




Re: memory usage


Return to index


Author

Message

Michael Philbrick

Posted: 03/16/2005 8:07:15


Sergey,


I have more information for you. I have narrowed it down to the code below.

In summary, I take a database BLOB field, uncompress it using VCLZip (UncompressBLOB),

store it in a TMemoryStream, and call the InsertRVFFromStreamEd method repeatedly,

clearing the TRichViewEdit component and reloading the same stream.


Note that in Button1Click there are two cases.


Test case 1: I uncompress the BLOB directly into MS_Dest. Each time the timer

fires I call InsertRVFFromStreamEd. This is the case that slows with each

cycle, approximately increasing the processing time by 50% each cycle.


Test case 2: I uncompress the BLOB into a stream, load the stream into a

TRichViewEdit component, then save the contents to another stream. It is

this stream that loads when I call InsertRVFFromStreamEd. This is the case

that works normally with no change in processing speed.


Frankly, I am suspicious about VCLZip. In order to rule it out as the problem,

I also tried the TStream.CopyFrom method so that the stream VCLZip created

was copied into a separate stream while the original stream was destroyed.

I figured this would break any links with the VCLZip archive. Unfortunately,

it did not change the outcome. So, it appears that when the stream is created

by a component other than TRichViewEdit I have the problem.


I am not sure what advice you can offer, but any would be helpful!


Michael Philbrick


procedure TForm1.UncompressBLOB(stArchive : TStream; stOutput : TMemoryStream);

begin

  try

    // assign ArchiveStream to blob stream

    VCLZip.ArchiveStream := stArchive;

    // decompress data from blob archive stream, save into memory stream

    VCLZip.UnZipToStream(stOutput, 'DummyFileName');

    // go to stream start position for later LoadFromStream

    stOutput.Seek(0,0);

  finally

    // detach archive stream

    VCLZip.ArchiveStream := nil;

  end;

end;


procedure TForm1.Button1Click(Sender: TObject);

var

  TimeStart     : TDateTime;

begin

  Memo1.Clear;

  if Button1.Caption = 'Start' then begin

    MS_Source := TMemoryStream.Create;

    MS_Dest := TMemoryStream.Create;

    MS_Hold := TMemoryStream.Create;

    TBlobField(dmServerMod.tbsCommunications.FieldByName(

         'com_text')).SaveToStream(MS_Source);


// test case 1

    UncompressBLOB(MS_Source, MS_Dest);

// end of test case 1


// test case 2

    UncompressBLOB(MS_Source, MS_Hold);

    MS_Hold.Seek(0,0);

    rvCommHold.InsertRVFFromStreamEd(MS_Hold);

    rvCommHold.SaveRVFToStream(MS_Dest, False);

// end of test case 2


    Button1.Caption := 'Stop';

    rvComm.ReadOnly := False;

    Timer1.Enabled := True;

  end else begin

    Button1.Caption := 'Start';

    MS_Source.Free;

    MS_Dest.Free;

    MS_Hold.Free;

  end;

end;


procedure TForm1.Timer1Timer(Sender: TObject);

var

  StartTime : TDateTime;

begin

  Timer1.Enabled := False;

  if Button1.Caption <> 'Stop' then

    Exit;

  StartTime := Now;

  with rvComm do begin

    Clear;

    Format;

    MS_Dest.Seek(0,0);

    InsertRVFFromStreamEd(MS_Dest);

    Format;

  end;

  Memo1.Lines.Add(FormatDateTime('ss:zzz', Now-StartTime));

  Timer1.Enabled := True;

end;





Powered by ABC Amber Outlook Express Converter