php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11235 DB2 ODBC driver memory leak
Submitted: 2001-06-01 07:00 UTC Modified: 2002-05-21 23:40 UTC
From: s dot boganov at kochmedia dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.5 OS: SUSE Linux 7.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: s dot boganov at kochmedia dot com
New email:
PHP Version: OS:

 

 [2001-06-01 07:00 UTC] s dot boganov at kochmedia dot 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-01 13:34 UTC] kalowsky@php.net
how have you determined that php is using this memory?
 [2001-06-02 03:20 UTC] s dot boganov at kochmedia dot 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-05 19:57 UTC] 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-11 10:11 UTC] kalowsky@php.net
duplicate of 8346... although same patch is in the cvs.

it seems that DB2 does not support the SQL_CURSOR_DYNAMIC.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 08:01:35 2024 UTC