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: 2020-12-27 04:22 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:3 (75.0%)
From: istvan at dupai dot hu Assigned:
Status: No Feedback Package: MySQLi related
PHP Version: 7.3.1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 - 2 = ?
Subscribe to this entry?

 
 [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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-07 11:05 UTC] thomas dot kosel at aspera dot com
I can reproduce this on 7.3.6 in a docker environment
The issue did not apply, when the prepare and bind parts are in the loop too.
 [2020-12-18 09:42 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2020-12-18 09:42 UTC] nikic@php.net
I can't reproduce this. I think early 7.3 versions did have issues with result set leaks, so I suspect this has already been fixed in the meantime. Do you still see this issue?
 [2020-12-27 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri May 14 11:01:23 2021 UTC