php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77495 STMT execute memory leak
Submitted: 2019-01-21 00:47 UTC Modified: -
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: istvan at dupai dot hu Assigned:
Status: Open Package: MySQLi related
PHP Version: 7.3.1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: istvan at dupai dot hu
New email:
PHP Version: OS:

 

 [2019-01-21 00:47 UTC] istvan at dupai dot hu
Description:
------------
MySQLi prepared statement execution in a loop increases memory consumption rapidly constantly.

Test script:
---------------
$now = microtime(true);
$db = new \Mysqli("localhost", "root", "password", "database", 3306);

$stmt = $db->prepare("SELECT * FROM someTable WHERE id=?");
$stmt->bind_param("i", $id);

for( $id=1; $id<1000; $id++ ) {
    $stmt->execute();
    $result = $stmt->get_result();
    $stmt->free_result();
}

echo "Time taken: ".(microtime(true)-$now)." seconds\n";
echo "Peak memory usage: ".number_format(memory_get_peak_usage())." bytes\n";

Expected result:
----------------
Memory usage should peak and stay around 400 KBs.

Actual result:
--------------
Memory usage constantly grows.

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Feb 23 00:01:25 2019 UTC