Excessive use of memory when doing multiple connection attach/detach calls.
---------------------------------------------------------------------------
Key: CORE-3702
URL: http://tracker.firebirdsql.org/browse/CORE-3702
Project: Firebird Core
Issue Type: Bug
Components: API / Client Library
Affects Versions: 2.5.1
Environment: Win7 64bit (using 32bit client)
Reporter: Jason Wharton
Priority: Critical
Here is a Delphi sample app that will reproduce this problem.
Start a fresh new application with a main form.
Put a private variable as follows:
MyCount: integer;
Put a button on the form named btProb.
Add this in the uses clause:
IB_Header, IB_Session;
Assign an OnClick handler for the btProb button as follows:
procedure TfrmMemLeak.btProbClick(Sender: TObject);
var
dbh: isc_db_handle;
rb: RawByteString;
dpb: array[0..19] of byte;
errcode: isc_status;
status: status_vector;
begin
if MyCount = 0 then
MyCount := 5000
else
MyCount := 0;
// rb := 'localhost:c:\cps-data\ibdb\test_ib_XE.fdb';
rb := 'localhost:c:\cps-data\ibdb\test.fdb';
dpb[ 0] := 1; //isc_dpb_version1
dpb[ 1] := 28; //isc_dpb_user_name
dpb[ 2] := 6; //6 bytes long
dpb[ 3] := 83; //S
dpb[ 4] := 89; //Y
dpb[ 5] := 83; //S
dpb[ 6] := 68; //D
dpb[ 7] := 66; //B
dpb[ 8] := 65; //A
dpb[ 9] := 29; //isc_dpb_password
dpb[10] := 9; //9 bytes long
dpb[11] := 109; //m
dpb[12] := 97; //a
dpb[13] := 115; //s
dpb[14] := 116; //t
dpb[15] := 101; //e
dpb[16] := 114; //r
dpb[17] := 107; //k
dpb[18] := 101; //e
dpb[19] := 121; //y
dbh := nil;
if MyCount > 0 then
begin
try
if not Assigned( isc_attach_database ) then
RevertToOriginalHooks;
btProb.Caption := 'Prob...';
while MyCount > 0 do
begin
errcode := isc_attach_database( @status,
Length(rb),
PByte(rb),
@dbh,
SizeOf( dpb ),
@dpb );
if errcode = 0 then
errcode := isc_detach_database( @status, @dbh );
if errcode<> 0 then
raise Exception.Create( 'Errcode: ' + IntToStr(errcode) );
Dec( MyCount );
Application.ProcessMessages;
end;
finally
MyCount := 0;
btProb.Caption := 'Prob'
end;
end;
end;
Modify the connect path, username and password in the code above to match a
valid database on your machine and your server's sysdba account.
Then compile and run but don't click the button just yet.
Run Win7's "Resource Monitor" (search on start menu should find it) and then go
to where it will monitor memory on a per-process basis. Look for the name of
your program in the list of processes and select it so you can follow it. You
will be watching the Physical Memory column for the undesirable growth.
Click on the button to run the loop of attaching and detaching from your
database.
You should notice that the memory used by your program is increasing steadily.
Not at a super fast rate but at a rate fast enough that it makes Firebird
unusable for a server process that must have an uptime of many days and weeks.
Jason
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel