ID:               40121
 User updated by:  [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         PDO related
 Operating System: Mac OS X 10.4.8
 PHP Version:      5.2.1RC2
 New Comment:

After playing around with GDB I noticed that the S->cols is 
being allocated on different memory block each time. S and S-
>rows stay in the same place, though. I suppose this is due 
the different methods used to allocate memory, but I just 
don't have enough clue to fix it.


Previous Comments:
------------------------------------------------------------------------

[2007-01-14 21:50:40] [EMAIL PROTECTED]

I couldn't get it to compile, so I corrected the mysql -> 
dblib, not sure whether this was the intention though. I 
don't have enough karma, so the patch is below:

RCS file: /repository/php-src/ext/pdo_dblib/dblib_stmt.c,v
retrieving revision 1.6.2.2.2.3
diff -u -r1.6.2.2.2.3 dblib_stmt.c
--- dblib_stmt.c        14 Jan 2007 16:57:50 -0000      
1.6.2.2.2.3
+++ dblib_stmt.c        14 Jan 2007 21:43:35 -0000
@@ -250,9 +250,9 @@
        return 1;
 }
 
-static int dblib_mysql_stmt_cursor_closer(pdo_stmt_t *stmt 
TSRMLS_DC)
+static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt 
TSRMLS_DC)
 {
-       pdo_dblib_stmt *S = (pdo_mysql_stmt*)stmt-
>driver_data;
+       pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt-
>driver_data;
 
        if (S->rows) {
                free_rows(S TSRMLS_CC);
@@ -273,6 +273,6 @@
        NULL, /* get attr */
        NULL, /* meta */
        NULL, /* nextrow */
-       dblib_mysql_stmt_cursor_closer
+       pdo_dblib_stmt_cursor_closer
 };


However, it doesn't fix the problem. See, gdb breaks fine on 
pdo_dblib_stmt_dtor on each iteration and stepping it shows 
that it even attempts to free stuff. So I guess the error 
isn't here?

After running gdb with patch above it does close the cursor 
on each iteration, but it's not still affecting the 
increasing memory usage.

------------------------------------------------------------------------

[2007-01-14 16:57:56] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.



------------------------------------------------------------------------

[2007-01-13 18:23:10] [EMAIL PROTECTED]

Forgot to mention that it works perfectly with MySQL driver.

------------------------------------------------------------------------

[2007-01-13 18:19:43] [EMAIL PROTECTED]

Description:
------------
As stated on the summary, PDO DBLIB driver wont free memory 
allocated to statements (or the resultset, not sure). Same 
code done with ext/mssql functions works, though.

Reproduce code:
---------------
$db = new PDO('dblib:host=hostname;dbname=database', 'user',
'password');
$query = 'SELECT GETDATE()'; // NOW() on mysql

for ($i = 0; $i < 10; $i++) {
    $stmt = $db->query($query); // new statement
    $stmt->fetch();             // actual data
    $stmt->fetch();             // false; end of resultset
    $stmt->closeCursor();       // this should at least free it,
right?
    $stmt = null;               // being paranoid here

    echo memory_get_usage() . "\n";
}

Expected result:
----------------
54152
54152
54152
54152
54152
54152
54152
54152
54152
54152

Actual result:
--------------
54152
54252
54292
54332
54372
54412
54452
54492
54532
54572


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40121&edit=1

Reply via email to