>Micha wrote:
>This is a memory leak, plus you should never create TStreams anyway.

I made all changed suggested, you can see latest GETMEMO function
bellow.

>Micha wrote:
>Do you have an example project plus dbf/dbt to test with ?

Trying to prepare sample database and project, I created a smaller
version of the database on which same GETMEMO function operates
normally. This small version of the database includes 500 records. Main
database includes near to 300.000 records. Changing only databases I get
sample project running normally with small size but hanging with large
version.

Now, the sample project along with sample database is about 180 MB. It
will take long time to upload it and of course for you to download it.
If you agree I can do it anyway but, Is there any other option such as
sending to you in a CD by courier? If yes, please send your mail address
at [EMAIL PROTECTED] and I will manage the rest.

Thank you very much for your help.

Regards, Panagiotis

-----------------
function spGetMEMOField( tTable: TDbf; cFieldName: string ): string;
var
   tsMemoStream: Tstream;
   pBuffer: pchar;
   sMemo: string;
   nCounter, nStopChar: integer;

begin
     tsMemoStream := TTable.CreateBlobStream( TTable.FieldByName(
cFieldName ), bmRead );

     pBuffer := GetMem( tsMemoStream.Size + 1 );
     tsMemoStream.Position := 0;
     tsMemoStream.read( pBuffer^, tsMemoStream.Size + 1 );
     sMemo := strpas( pBuffer );

     Freemem( pBuffer );
     tsMemostream.free;

     Result := sMemo;
end;
-----------------

-----------------------------------------
MAGENTA LTD
47-51 Methonis str - 106 81 Athens Greece
Shared cost phone 801-11.711.711
Standard rates for calls from abroad
or mobile phones
(+30) 210-33.03.920, 33.03.965
Fax (+30) 210-33.03.216
Company profile:
http://www.magenta.gr/en/profile.htm
-----------------------------------------
http://www.magenta.gr     [EMAIL PROTECTED]
-----------------------------------------

-----Original Message-----
From: Micha Nelissen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 08, 2006 5:15 PM
To: [email protected]
Subject: Re: [lazarus] TDBF: Read MEMO field problem


Panagiotis Sidiropoulos wrote:
> --------------------------------
> // READ MEMO FIELD
> function spGetMEMOField( tTable: TDbf; cFieldName: string ): string; 
> var
>    tsMemoStream: Tstream;
>    pBuffer: pchar;
>    sMemo: string;
>    
> begin
>      tsMemoStream := TStream.Create;

This is a memory leak, plus you should never create TStreams anyway.

>      tsMemoStream := TTable.CreateBlobStream( TTable.FieldByName( 
> cFieldName ), bmRead );
>      tsMemoStream.Position := 0;
>      pBuffer := GetMem( 200000 );

Better use tsMemoStream.Size instead of fixed size.

>      tsMemoStream.read( pBuffer^, 200000 );

Dito.

>      sMemo := strpas( pBuffer );

Besides this, I cannot really see why it would be slow. Do you have an 
example project plus dbf/dbt to test with ?

Micha

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to