Bug #71468 [Com]: increased memory usage with mysqli in php 7

From: Date: Wed, 15 Feb 2017 09:53:07 +0000
Subject: Bug #71468 [Com]: increased memory usage with mysqli in php 7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207388@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71468&edit=1

 ID:                 71468
 Comment by:         amigojack at gmx dot net
 Reported by:        ryan dot brothers at gmail dot com
 Summary:            increased memory usage with mysqli in php 7
 Status:             Not a bug
 Type:               Bug
 Package:            MySQLi related
 Operating System:   Linux
 PHP Version:        7.0.2
 Block user comment: N
 Private report:     N

 New Comment:

Using PHP 7.0.15-1~dotdeb+8.1 or 7.1.1 also gives me the same problem in contrast to PHP 5.6
version: executing a simple query thru MYSQLi ("SELECT text FROM table WHERE text LIKE
'%url%'"), where the given column is datatype TEXT and the overall result has about
1M of rows.

The script exactly always dies upon calling mysqli_query(). PHP 5.6 had a memory limit of 384M which
worked fine. I increased the memory limit of 7.0.15-1~dotdeb+8.1 to 2048M and it still wasn't
enough! How on earth...?

No, mysqli_query() must have changed largely. Or are you telling me PHP 5.6 didn't die on
exhausted memory just because the DBMS itself was using more than 2G of memory without reporting it
to PHP?


Previous Comments:
------------------------------------------------------------------------
[2016-05-14 21:56:57] nikic@php.net

The aforementioned change will be part of PHP 7.1.

I'm not sure I understand what your issue is. As said, the actual memory usage did not
increase, only the way it is reported changed. You can safely raise the memory_limit to account for
this.

------------------------------------------------------------------------
[2016-05-14 20:49:18] ryan dot brothers at gmail dot com

Thanks for your help.  Have your changes been merged into a release?  I'm still seeing similar
memory usage in PHP 7.0.6 where my scripts are hitting the memory limit, but they didn't in PHP
5.6.  Can more be done to optimize memory usage in mysqlnd?  Can this ticket be re-opened, or should
I open a new ticket?  Thanks.

------------------------------------------------------------------------
[2016-02-22 18:46:59] nikic@php.net

I've implemented some tweaks in master to reduce memory usage for this case
(https://github.com/php/php-src/commit/2d1559f827477963a3f8a40af64212a409ba9457). There's more
that can be done here, but this was the lowest hanging fruit.

------------------------------------------------------------------------
[2016-02-22 18:23:25] rendername at gmail dot com

Ok, we maked new tests to see, how much memory was used for mysqli_query on process:
PHP5: before query 23m, after 237m => so we have 214m (memory_get_usage 45m) NOT OK
PHP7: before query 20m, after 270m => so we have 250m (memory_get_usage 250m) OK

So, php7 need a little more memory for this query, but we get memory usage correctly.

------------------------------------------------------------------------
[2016-02-22 16:18:41] ryan dot brothers at gmail dot com

Thanks for the feedback.  I understand the changes, but my scripts in PHP 7 are hitting the memory
limit when they didn't in PHP 5.6, yet one of the advantages of PHP 7 is reduced memory usage. 
Is there someone more familiar with the change in mysqlnd that can look into it further to determine
if PHP 7 will use more memory than PHP 5.6 and not less?

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


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=71468


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


Thread (15 messages)

« previous php.bugs (#207388) next »