Subject Re: [firebird-support] Unusual memory consumption on Firebird
Author Ivan Prenosil
> I have set up a Firebird 1.5.2 classic database on Windows XP. It has
> one table (CHUNK) with 3 columns:
> - UUID VARCHAR(16) not-null unique indexed
> - IndexedLocation VARCHAR(250) not-null indexed
> - LocationPart1 VARCHAR(32700)
> - LocationPart2 VARCHAR(32700)
>
> I am using the C-API exposed by fbclient.dll. In my test program, I
> created 100,000 records with UUID and IndexedLocation populated with
> test values (LocationPart1 and Part2 are NULL) - this seemed to go
> well; I got a reasonable number of insertions/sec. and memory usage
> seems to be well under control.
> The C function calls I make for a write are the following:
> - isc_start_transaction
> - isc_dsql_execute_immediate
> - isc_commit_transaction

It must be very slow, for mass insert it is much better to prepare the statement
only once, and execute it repeatedly with different parameters.

>
> However, when I tried to read records (by indexedLocation), memory
> consumed by fbserver seemed to keep increasing continuously at a
> rapid rate with every call until I ran out of virtual memory on the
> machine.

Because you are not freeing statement handles.

Ivan

>
> The C function calls I make for every access are the following:
> - isc_start_transaction
> - isc_dsql_allocate_statement
> - isc_dsql_prepare
> - isc_dsql_execute
> - isc_dsql_fetch
> - isc_commit_transaction
> The SQL executed is:
> SELECT uuid, locationPart1, locationPart2 from CHUNK where
> indexedLocation = ?;
>
> If I do an isc_attach_database() at the begining followed by an
> isc_detach_database() at the end, memory does not keep increasing;
> however the number of reads/sec. drops drastically (as expected). Am
> I doing something wrong, in terms of the calls I am using? I would
> think it is not necessary to keep attaching to and detaching from the
> database every time I need to get a record. The increased memory
> usage is not in my test application, but in the fbserver process
> itself.
>
> Any help would be greatly appreciated.
> Thanks.