Bug #67898 [Com]: Memory allocation problem - memory not freed
| From: | tomas at slax dot org | Date: | Mon, 01 Sep 2014 19:22:17 +0000 |
| Subject: | Bug #67898 [Com]: Memory allocation problem - memory not freed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187373@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67898&edit=1
ID: 67898
Comment by: tomas at slax dot org
Reported by: tomas at slax dot org
Summary: Memory allocation problem - memory not freed
Status: Open
Type: Bug
Package: MySQL related
Operating System: Slackware Linux
PHP Version: 5.5.16
Block user comment: N
Private report: N
New Comment:
Test it yourself, with this simple script:
<?php
echo "connecting to database...\n";
$link=mysqli_connect("localhost",'root','','test');
echo "creating table with lots of rows...\n";
mysqli_query($link,"CREATE TEMPORARY TABLE tbl123 LIKE mysql.user");
for ($i=0;$i<6000; $i++)
{
mysqli_query($link,"INSERT IGNORE INTO tbl123 SET
host='x".$i."'");
}
echo "getting all rows from database\n";
$result=mysqli_query($link,"SELECT * FROM tbl123");
while($row=mysqli_fetch_row($result))
{
echo "Mem used:
".number_format(memory_get_usage()/1024,1,'.','')." KB\n";
}
// expected result: memory usage still the same
// Actual result: memory usage increases with each row :(
?>
Previous Comments:
------------------------------------------------------------------------
[2014-09-01 17:58:58] tomas at slax dot org
Thank you for your reply.
I'm not sure what difference are you mentioning.
There is NO DIFFERENCE AT ALL.
The memory problem is there for both, mysql_* and mysqli_* functions. It's the same.
------------------------------------------------------------------------
[2014-09-01 14:49:36] johannes@php.net
mind that
1) mysql_* APIs are deprecated and should not be used,
2) mysql_query is buffering the result set so it's all in memory and
3) your difference comes from using libmysql vs mysqlnd as client library, mysqlnd uses PHP memory
and therefore PHP reports more accurate memory usage, with libmysql memory used inside the library
is hidden
------------------------------------------------------------------------
[2014-08-29 20:45:32] tomas at slax dot org
I was unable to get the mentioned memory error with Debian's PHP 5.4.4-14+deb7u14 (tested only
with the CLI binary). The memory is properly freed there. However when I took the sources + patches
from debian, and compiled on the very same debian box, the memory issue is there again. I tried with
simple ./configure --with-mysql --with-mysqli, the compiled binary has the problem with memory which
is not freed.
This is very odd. If anybody helps me to replicate Debian's compilation then I could maybe
track down what option is responsible...
------------------------------------------------------------------------
[2014-08-24 18:59:36] tomas at slax dot org
I was able to confirm that the bug is not there in PHP 5.3.29.
So it was introduced in 5.4.x .. oh my god this is serious, so many years ...
I am unable to find sources for PHP 5.4.0 for test. Ideas?
------------------------------------------------------------------------
[2014-08-24 17:57:35] tomas at slax dot org
The same issue can be observed on PHP 5.4.20.
The same issue can be reproduces on PHP 5.6.0RC4 :(
All compiled on Slackware Linux.
------------------------------------------------------------------------
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=67898
--
Edit this bug report at https://bugs.php.net/bug.php?id=67898&edit=1