Karol Bieniaszewski wrote:

Why concating blob consume memory and not leave it until transaction end?

simple sample:

SET TERM ^ ;

CREATE PROCEDURE TEST_BLOB_CONCAT
 ( A BLOB SUB_TYPE TEXT, ILE INTEGER )
RETURNS
 ( B BLOB SUB_TYPE TEXT )
AS
DECLARE VARIABLE VAR_I INTEGER;
BEGIN
  VAR_I = 0;
  B = 'ABC';
  WHILE (VAR_I<ILE) DO
    BEGIN
      B = B || A;
      VAR_I = VAR_I + 1;
    END
  SUSPEND;
END^

SET TERM ; ^

For 5000 operations:

SELECT * FROM TEST_BLOB_CONCAT('', 5000)
result 'ABC'

memory usage:
        used: 12208
         max: 38112
   allocated: 65536
allocatedmax: 65536

For 500000 operations:

SELECT * FROM TEST_BLOB_CONCAT('', 500000)
result 'ABC'

memory usage:
        used: 12208
         max: 2338208
   allocated: 2359296
allocatedmax: 2359296

For 50000000 operations:

SELECT * FROM TEST_BLOB_CONCAT('', 50000000)
result 'ABC'

Consumes all memory from operating system!

It looks like some temp buffers are created and not freed until transaction end Is this bug reported or i should report it to the tracker?

Helen Borrrie answers:

Currently, internal (created by the engine, not by user) temporary blob's are released together with parent transaction.

Firebird 2.5.4 and 3.0 beta 2 were improved by binding such temporary blob to request, which allows to release blob (and related memorydisk space) when request execution is finished (or request's cursor is closed). In some cases it is earlier then transaction commit (rollback) thus allows to release resources more quickly.

See http://tracker.firebirdsql.org/browse/CORE-4671

Like this post? Share on: TwitterFacebookEmail


Related Articles


Author

Firebird Community

Published

Category

Gems from Firebird Support list

Tags