php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77713 Memory exhausted using mysqli_use_result()
Submitted: 2019-03-08 19:29 UTC Modified: 2019-03-22 12:15 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: data dot protection dot gdpr at gmail dot com Assigned:
Status: Duplicate Package: MySQLi related
PHP Version: 7.3.3 OS: CentOS 6
Private report: No CVE-ID: None
 [2019-03-08 19:29 UTC] data dot protection dot gdpr at gmail dot com
Description:
------------
In PHP 7.2, this was running very well.

Since the upgrade to PHP 7.3, very quickly I get a "memory exhausted" error in the mysqli_fetch_assoc() call, at around result #850000.
Increasing "memory_limit" helps getting more results, but the error is always on mysqli_fetch_assoc(), so I'm very confident the problem is there.


The data retrieved by the SELECT is very small (no big blobs), so there is no bad row that I'm hitting that causes the memory issue.

Isn't the point of "use_result" not putting everything in memory and being able to go through huge amount of results?

Am I doing something wrong? Is there a way to flush the previous read results?

Test script:
---------------
mysqli_real_query($conn, 'SELECT id, name FROM big_table WHERE ... ORDER BY ... LIMIT 1500000);
$result = mysqli_use_result($conn);
<... error handling here ...>

while ($row = mysqli_fetch_assoc($result)) {
 <... do stuff ...>
}
mysqli_free_result($result);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-15 16:50 UTC] data dot protection dot gdpr at gmail dot com
Just to confirm, I reverted to PHP 7.2 and put "memory_limit" back to default. The process works fine now.

Then I upgraded again to PHP 7.3, and I get the "memory exhausted" error again.
 [2019-03-22 12:15 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2019-03-22 12:15 UTC] nikic@php.net
Same issue as bug #77773, which should be fixed now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC