Subject | UDF or UDF calling process of Firebird may cause memory leaking |
---|---|
Author | wenbin.pan |
Post date | 2007-11-29T18:02:23Z |
I am hit a memory leaking problem with Firebird UDF under Windows XP.
Here is what I did:
1. First create a stored procedure 'UDF_TEST' with just one UDF
function 'F_STRINGLENGTH'.
SET TERM ^ ;
CREATE PROCEDURE UDF_TEST
AS
DECLARE VARIABLE STR_1 VARCHAR(20);
DECLARE VARIABLE POS_1 INTEGER;
DECLARE VARIABLE IDX INTEGER;
BEGIN
STR_1 = '10-A-10';
IDX = 0;
WHILE (IDX <= 20000) DO
BEGIN
/* UDF function */
POS_1 = F_STRINGLENGTH(STR_1);
IDX = IDX + 1;
END
END^
SET TERM ; ^
2. Open the Windows Task Manager.
3. Execute the stored procedure, and watch the memory usage.
4. Run the stored procedure several times, the Firebird will raise the
following exception and the leaking memory has been released.
*** IBPP::SQLException ***
Context: Statement::Execute( EXECUTE PROCEDURE MEM_TEST )
Message: isc_dsql_execute2 failed
SQL Message : -902
Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements
Engine Code : 335544721
Engine Message :
Unable to complete network request to host "localhost".
Error reading data from the connection.
If I put the UDF function statement in the comment, and execute the
stored procedure. There would be no memory leaking problem.
Then I execute the following UDF function statement 1000 times:
SELECT F_STRINGLENGTH('10-A-10') FROM RDB$DATABASE;
The memory usage is clearly growing up.
Then I disconnect the database, those used memory was not released.
This problem can reproduced on 2 desktops. I think both of the
desktops have the same environment:
Operation System: Windows XP Pro
Firebird: Firebird 2.0.1 (Win32 Build)
UDF: 2007-02-09
Anyone has any idea if I did something wrong. Or there is the way to
work around the problem. Your help is appreciated.
Here is what I did:
1. First create a stored procedure 'UDF_TEST' with just one UDF
function 'F_STRINGLENGTH'.
SET TERM ^ ;
CREATE PROCEDURE UDF_TEST
AS
DECLARE VARIABLE STR_1 VARCHAR(20);
DECLARE VARIABLE POS_1 INTEGER;
DECLARE VARIABLE IDX INTEGER;
BEGIN
STR_1 = '10-A-10';
IDX = 0;
WHILE (IDX <= 20000) DO
BEGIN
/* UDF function */
POS_1 = F_STRINGLENGTH(STR_1);
IDX = IDX + 1;
END
END^
SET TERM ; ^
2. Open the Windows Task Manager.
3. Execute the stored procedure, and watch the memory usage.
4. Run the stored procedure several times, the Firebird will raise the
following exception and the leaking memory has been released.
*** IBPP::SQLException ***
Context: Statement::Execute( EXECUTE PROCEDURE MEM_TEST )
Message: isc_dsql_execute2 failed
SQL Message : -902
Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements
Engine Code : 335544721
Engine Message :
Unable to complete network request to host "localhost".
Error reading data from the connection.
If I put the UDF function statement in the comment, and execute the
stored procedure. There would be no memory leaking problem.
Then I execute the following UDF function statement 1000 times:
SELECT F_STRINGLENGTH('10-A-10') FROM RDB$DATABASE;
The memory usage is clearly growing up.
Then I disconnect the database, those used memory was not released.
This problem can reproduced on 2 desktops. I think both of the
desktops have the same environment:
Operation System: Windows XP Pro
Firebird: Firebird 2.0.1 (Win32 Build)
UDF: 2007-02-09
Anyone has any idea if I did something wrong. Or there is the way to
work around the problem. Your help is appreciated.