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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC