Bug #11235 Updated: DB2 ODBC driver memory leak

From: Date: Wed, 22 May 2002 03:40:49 +0000
Subject: Bug #11235 Updated: DB2 ODBC driver memory leak
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-8159@lists.php.net to get a copy of this message
ID: 11235 Updated by: kalowsky@php.net Reported By: s.boganov@kochmedia.com -Status: Duplicate +Status: Closed Bug Type: ODBC related Operating System: SUSE Linux 7.0 PHP Version: 4.0.5 Previous Comments: ------------------------------------------------------------------------ [2001-06-11 10:11:20] kalowsky@php.net duplicate of 8346... although same patch is in the cvs. it seems that DB2 does not support the SQL_CURSOR_DYNAMIC. ------------------------------------------------------------------------ [2001-06-05 19:57:49] kalowsky@php.net will you please test this patch on your version of PHP? it will require you to update to the 4.0.6 RC branch of PHP though.... it basically implements what you've suggested. Index: php_odbc.c =================================================================== RCS file: /repository/php4/ext/odbc/php_odbc.c,v retrieving revision 1.84.2.2 diff -u -r1.84.2.2 php_odbc.c --- php_odbc.c 2001/06/01 05:02:32 1.84.2.2 +++ php_odbc.c 2001/06/05 17:57:19 @@ -1871,6 +1871,16 @@ } ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); + if (result->values) { + for (i = 0; i < result->numcols; i++) { + if (result->values[i].value) { + efree(result->values[i].value); + } + } + efree(result->values); + result->values = NULL; + } + zend_list_delete(result->id); RETURN_TRUE; ------------------------------------------------------------------------ [2001-06-02 03:20:38] s.boganov@kochmedia.com I developed small application with WWW and DB2. After finished my work, I see - httpd crash after 2 hours works with diagnostic - 'no more memory'. I try to find this bugs in your 'Bugs database' and find recomendation upgrade to php 4.0.5 After this upgrade, all works fine - memory is free after execute command 'odbc_close', but memory isn't free after 'odbc_free_result' Look to the code 'php_odbc.c'. Probably, function 'odbc_free_result' will contain code like this: if (result->values) { for(i = 0; i < result->numcols; i++) { if (result->values[i].value) efree(result->values[i].value); } efree(result->values); result->values = NULL; } ( this code from 'odbc_next_result' function ) but I don't see any code like this .... Anyway, command 'top' show very high memory use, and my test program use ~100MB for operation, but as it describe in documentation my test programm will use a littlr bit memory.... ------------------------------------------------------------------------ [2001-06-01 13:34:33] kalowsky@php.net how have you determined that php is using this memory? ------------------------------------------------------------------------ [2001-06-01 07:00:41] s.boganov@kochmedia.com The function odbc_free_result() is not return memory. Example: <?php $db = odbc_connect ("XX", "XXXXXX", "XXXXX"); for( $i=0; $i<1000;$i++) { $q = odbc_do ($db, "SELECT titel FROM produkte WHERE prid=68340"); odbc_free_result( $q ); } odbc_close( $db ); ?> httpd take ~100MB memory for this operation. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=11235&edit=1

« previous php.bugs (#8159) next »