Edit report at https://bugs.php.net/bug.php?id=54864&edit=1
ID: 54864
User updated by: jas at rephunter dot net
Reported by: jas at rephunter dot net
Summary: Memory leak associated with mysql connector
Status: Re-Opened
Type: Bug
Package: MySQLi related
Operating System: FreeBSD
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
I am the OP for this ticket. Our system, now at PHP 5.6.9, is once again experiencing a memory leak,
and in fact it is in the same script as in the original post.
I am planning to do some testing to see if unsetting things helps. But per the post from yesterday
from supraguy, that does not work.
Previous Comments:
------------------------------------------------------------------------
[2015-09-02 20:53:41] supraguy at yandex dot com
I run into the same problem as well. I use mysqli_query() and on each execution it increases by 50
or so bytes. I unset the crap out of everything and do mysqli_free_result() but still the number
keeps rising.
------------------------------------------------------------------------
[2015-05-17 19:26:24] pr0ger at free dot fr
Note : same leakage using mysql_fetch_row() or mysql_fetch_array()
------------------------------------------------------------------------
[2015-05-17 19:22:00] pr0ger at free dot fr
Reproduced the memory leakage in php 5.5.0 + win7
had to fetch through 10M lines of TINYTEXT string (randoms from 4 to 250 utf8 chars)
$pt = mysql_query("SELECT tinytext_data, int_primkey FROM buffer");
while ($line = mysql_fetch_array($pt))
{
//doesnt need to do anything
echo "\r\n". memory_get_usage();
}
at each step, it increase the mem usage by 64 bytes, never freeing them.
------------------------------------------------------------------------
[2013-02-18 00:34:51] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2011-10-18 21:19:34] andrey@php.net
Hi,
I suppose there is no problem but the following occurs. Before 5.3 PHP used libmysql as underlying
library. Since 5.3 there is an option to use PHP's implementation of the client/server
protocol, the mysqlnd library. This library uses PHP's memory allocation functions, thus
affects memory_get_usage(). When you used libmysql and it allocated memory, this memory wasn't
reported by memory_get_usage() because the latter counts only the memory allocated by the PHP's
memory allocator.
To see if there is really a leak, you have to free your result sets and then dereference all the
variables which point to the result set. If the memory usage is still high, there could be a
problem. There is no problem, if you have created big SQL statement and later the reported used
memory is still high, because mysqlnd has a buffer onto which data packets are created. When big SQL
statement comes, the buffer needs to be enlarged and later it is not made smaller.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=54864
--
Edit this bug report at https://bugs.php.net/bug.php?id=54864&edit=1