[php-src] Issue #8089: leak in PDO and mysqli
| From: | Yurunsoft | Date: | Sun, 13 Feb 2022 02:25:12 +0000 |
| Subject: | [php-src] Issue #8089: leak in PDO and mysqli | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239716@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8089
Author: Yurunsoft
### Description
The following code:
```php
<?php
declare(strict_types=1);
function leakPDO()
{
$pdo = new PDO('mysql:host=127.0.0.1', 'root', 'root');
for ($i = 0; $i < 1000; ++$i)
{
$pdo->query('select ' . mt_rand());
}
}
function leakMysqli()
{
$mysqli = new mysqli('127.0.0.1', 'root', 'root');
for ($i = 0; $i < 1000; ++$i)
{
$mysqli->query('select ' . mt_rand());
}
$mysqli->close();
}
while (true)
{
leakPDO();
// leakMysqli();
echo 'input:',\PHP_EOL;
fread(\STDIN, 1);
}
```
Every time you press enter, php uses more memory.
I think this problem also exists in PHP 7.4, 8.1.
I'm using php to develop a memory resident application and this problem is bothering me.



### PHP Version
PHP 8.0.12
### Operating System
Ubuntu 20.04