Subject RE: [IBO] Large Blob Insertion
Author Brian Dunstan
Geoff,

> Brian,
>
> I am not quite convinced that the problem lies in IBO, but if it does
> then we need to isolate it better. To explain what I mean...
>
> If I use a memo control to insert 2Mb of text, IB_ReallocMem is called
> once for the entire size required. This happens because the TStrings
> class does a direct assignment from stream to stream.
>
> I have not got anything setup, but it appears that when you assign a
> stream (rather than TStrings) to a TIB_BlobStream, IBO uses the
> TStream CopyFrom method which does use a buffer - but that buffer is
> $F000 in size (60k) unless the supplied count is less than that. ie.
>
> if Count > $F000 then
> BufSize := $F000
> else
> BufSize := Count;
>
> So while using CopyFrom may not be ideal (Jason?) it should not be
> giving the results you are seeing at the moment.
>
>
> > FDataLink.Field.Assign(ILines);
>
> "ILines" - is that a TStringList derivation or a TStream derivation?

TwwCustomRichEdit = class(TCustomRichEdit)

Function TwwCustomRichEdit.ILines: TStrings;
begin
result:= inherited Lines;
end;

So I guess this means ILines is a TStrings because TCustomRichEdit declares
'Lines' as:
property Lines: TStrings read FRichEditStrings write SetRichEditStrings;

> I think that it must be a TStream or it could not embed a picture -
> although perhaps it converts to hex or base64.
>
>
> > which causes CreateBlobStream to be called
> > which calls TIBOBlobStream.Create
> > which calls TIB_BlobStream.Create
>
> The problem here is that I cannot see how the assignment from stream
> to stream is achieved. It can go either way.
>
> eg. ControlStream.SaveToStream( IBOStream )
> or IBOStream.Stream.LoadFromStream( ControlStream )
>
> Do you see what I mean? If it is the second version then I can see in
> the IBO code what is (or should be) happening. If it is the first
> version then the actual transfer code may exist in a different stream
> class that I dont have the code for.
>

I was hoping to see something like that too, but couldn't find it :-(


> Can you stick a breakpoint in the ib_reallocmem function and post the
> callstack details. (Perhaps run through a couple of calls to ensure
> we are looking at the particular/problem allocation.

This is the call stack on the first entry into IB_ReallocMem

IB_ReallocMem(nil,0,4095)
TIB_BlobStream.Write(???,4095)
TIBOBlobStream.Write(???,4095)
TwwCustomRichEdit.WndProc(???)
TwwDBRichEdit.UpdateData(???)
Project1

this is on the second entry:

IB_ReallocMem($E80000,4095,8190)
TIB_BlobStream.Write(???,4095)
TIBOBlobStream.Write(???,4095)
TwwCustomRichEdit.WndProc(???)
TwwDBRichEdit.UpdateData(???)
Project1

and this is the third:

IB_ReallocMem($E81004,8190,12285)
TIB_BlobStream.Write(???,4095)
TIBOBlobStream.Write(???,4095)
TwwCustomRichEdit.WndProc(???)
TwwDBRichEdit.UpdateData(???)
Project1

and so it goes... you can see the NewSize incrementing by 4095 on each call.


> Geoff Worboys
> Telesis Computing


Thanks for you help on this Geoff,

Brian