php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71469 mysqli_fetch_field increases memory usage by large amount
Submitted: 2016-01-28 00:22 UTC Modified: 2017-05-10 10:05 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:-1 (-100.0%)
From: ryan dot brothers at gmail dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.6.17 OS: Linux
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: ryan dot brothers at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-28 00:22 UTC] ryan dot brothers at gmail dot com
Description:
------------
I am seeing an issue in PHP 5.6.17 where after running a large database query, calling mysqli_fetch_field increases memory usage by a large amount.  The same issue occurs in PHP 7.0.2.

In the below example, the call to fetch_field increases the memory usage from 1.8MB to 6.6MB.

I have placed SQL to create a test table of 100,000 rows at https://drive.google.com/uc?export=download&id=0B37DKbJklxg_Y3NadnRjc2tVbE0.

Is this expected behavior or an issue with memory usage?

Thanks for your help.


Test script:
---------------
<?php
$mysqli = new mysqli('localhost', 'test', 'test', 'test');

$mysqli->real_query("SELECT * FROM a");

$result = $mysqli->store_result();

echo 'a: '.memory_get_usage()."\n";

$field = $result->fetch_field();

echo 'b: '.memory_get_usage()."\n";
exit;


Expected result:
----------------
a: 1833136
b: 1833136 (or close to it)


Actual result:
--------------
a: 1833136
b: 6635728


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-10 10:05 UTC] fjanisze@php.net
-Status: Open +Status: Not a bug
 [2017-05-10 10:05 UTC] fjanisze@php.net
Yes, that is expected.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 26 03:03:35 2021 UTC