Bug #71468 [Opn->Nab]: increased memory usage with mysqli in php 7

From: Date: Mon, 22 Feb 2016 15:38:17 +0000
Subject: Bug #71468 [Opn->Nab]: increased memory usage with mysqli in php 7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199393@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 Updated by: nikic@php.net Reported by: ryan dot brothers at gmail dot com Summary: increased memory usage with mysqli in php 7 -Status: Open +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: store_result uses mysqlnd mempool chunks. In PHP 5.6 those used the system allocator (http://lxr.php.net/xref/PHP_5_6/ext/mysqlnd/mysqlnd_block_alloc.c#120). In PHP 7.0 they use the Zend MM (http://lxr.php.net/xref/PHP_MASTER/ext/mysqlnd/mysqlnd_block_alloc.c#119). So the memory usage didn't actually change (or rather, it did change, but not in a bad way), it simply wasn't reported previously by memory_get_usage(). Previous Comments: ------------------------------------------------------------------------ [2016-02-22 14:36:08] ryan dot brothers at gmail dot com Yes, I am using mysqlnd. I confirmed I'm seeing the memory usage increase comparing the latest PHP 5.6.18 and PHP 7.0.3 using the reproduce script above. 5.6.18: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $ 7.0.3: mysqlnd 5.0.12-dev - 20150407 - $Id: f59eb767fe17a6679589b5c076d9fa88d3d4eac0 $ ------------------------------------------------------------------------ [2016-02-22 08:35:01] rendername at gmail dot com Of course, we use only mysqlnd: PHP 7 phpinfo() Client API library version mysqlnd 5.0.12-dev - 20150407 - $Id: f59eb767fe17a6679589b5c076d9fa88d3d4eac0 $ php7.0 -m|grep mysql mysqli mysqlnd pdo_mysql PHP 5 phpinfo() Client API version mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $ php5 -m|grep mysql mysql mysqli mysqlnd pdo_mysql New Example: (mysql table pays with 650k rows, getting ID numbers) ... echo round(memory_get_usage()/1024/1024)."m<br>"; $res=mysqli_query($db,"select id from pays"); echo round(memory_get_usage()/1024/1024)."m<br>"; die(); Output PHP7: 1m 52m Output PHP5: 1m 11m PHP7 need 5 times more memory for each Mysql Query We have debian 8 64 bit + Dotdeb packets with PHP7 ------------------------------------------------------------------------ [2016-02-22 05:43:48] rasmus@php.net Are you sure that your mysqli was compiled against mysqlnd in both PHP 5 and PHP 7? On your phpinfo() page, in the mysqli section, what does it say for "Client API library version" in both PHP 5 and 7? The reason being, if PHP 5 was compiled against libmysqlclient then since libmysqlclient does not use the PHP memory allocator none of the memory allocated by that library is reported by memory_get_usage(). That doesn't mean it wasn't allocated, of course. ------------------------------------------------------------------------ [2016-02-21 23:00:15] rendername at gmail dot com We have the same issue, does anyone have any idea? php5 - 45mb, php7 - 250mb Debian 8 (jessie) 64bit ------------------------------------------------------------------------ [2016-01-28 11:53:16] ryan dot brothers at gmail dot com Yes, mysqlnd is used in both. PHP was compiled with --with-mysqli. ------------------------------------------------------------------------ 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

« previous php.bugs (#199393) next »