[php-src] Issue #8089: leak in PDO and mysqli

From: 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. ![1](https://user-images.githubusercontent.com/20104656/153735529-40ffcca8-6d42-40e8-a93c-76bca00c01c2.png) ![2](https://user-images.githubusercontent.com/20104656/153735531-b10d1c97-0347-49c2-9c64-992838008903.png) ![3](https://user-images.githubusercontent.com/20104656/153735534-72095f7b-67b8-4990-8814-6355743375df.png) ### PHP Version PHP 8.0.12 ### Operating System Ubuntu 20.04

« previous php.bugs (#239716) next »