php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50820 mysqli Active Links memory leak
Submitted: 2010-01-22 07:05 UTC Modified: 2010-03-20 12:59 UTC
From: mat999 at gmail dot com Assigned:
Status: Closed Package: MySQLi related
PHP Version: 5.3.2 OS: Debian Lenny / Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mat999 at gmail dot com
New email:
PHP Version: OS:

 

 [2010-01-22 07:05 UTC] mat999 at gmail dot com
Description:
------------
System
 - mod_fastcgi. 1 process x 35 child php threads
 - PHP 5.3.1 dotdeb package
 - Mysqlnd

Active Links increases throught the running of the server, for one it is greater than the number of threads so there obviously is a leak.

PHPInfo: http://thewarezscene.org/phpinfo.php

Reproduce code:
---------------
<?
$db = mysqi_connect(....);
echo 'test';
mysqli_close($db);
?>

Open script a few thousand times and take a look at phpinfo()


Expected result:
----------------
Active Links  = 0;

Actual result:
--------------
Active Links  = XXXX;

http://thewarezscene.org/phpinfo.php
^ I have to kill all processes every 3 hours to keep the number down and hence the memory usage.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-22 09:00 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2010-01-24 09:13 UTC] mat999 at gmail dot com
Sorry I cant compile a development snapshot on this production machine.

The problem is existing on it, most likely due to fastcgi im am guessing. Should be easy to reproduce.

Heres a screenshot of the phpinfo below after 4 hours, 1540 active links which is 20 times my mysql max_connections limit, and 100 times my php children amount.

http://im4ge.info/show.php/128663_im4ge.png.html
 [2010-01-24 21:55 UTC] jani@php.net
Can not reproduce using latest SVN, considered closed.
 [2010-03-20 06:53 UTC] mat999 at gmail dot com
Ok, I have some code that reproduces this bug I believe.

<?php
for($i=0;$i<=100000;$i++){
    $m = mysqli_init();
    mysqli_real_connect($m,'localhost','root','passwordmysql');
    $m = mysqli_close($m);
    unset($m);
    if(($i%1000)===0){
        echo "Memory consumption after $i iterations is " . memory_get_usage() . "<br /><br />";
        flush();
    }
}
die();
?>



Result:
Memory consumption after 0 iterations is 660120

Memory consumption after 1000 iterations is 852600

Memory consumption after 2000 iterations is 1044832

Memory consumption after 3000 iterations is 1245216

Memory consumption after 4000 iterations is 1429224

Memory consumption after 5000 iterations is 1645992

Memory consumption after 6000 iterations is 1830000

Memory consumption after 7000 iterations is 2014000

Memory consumption after 8000 iterations is 2198016

Memory consumption after 9000 iterations is 2447552

Memory consumption after 10000 iterations is 2631608

Memory consumption after 11000 iterations is 2815608

Memory consumption after 12000 iterations is 2999616

Memory consumption after 13000 iterations is 3183624

Memory consumption after 14000 iterations is 3367624

Memory consumption after 15000 iterations is 3551640

Memory consumption after 16000 iterations is 3735648

Memory consumption after 17000 iterations is 4050720

Memory consumption after 18000 iterations is 4234728

Memory consumption after 19000 iterations is 4418728

Memory consumption after 20000 iterations is 4602736

Memory consumption after 21000 iterations is 4786744

Memory consumption after 22000 iterations is 4970744

Memory consumption after 23000 iterations is 5154760

Memory consumption after 24000 iterations is 5338768

Memory consumption after 25000 iterations is 5522776

Memory consumption after 26000 iterations is 5706776

Memory consumption after 27000 iterations is 5890792

Memory consumption after 28000 iterations is 6074800

Memory consumption after 29000 iterations is 6258800

Memory consumption after 30000 iterations is 6442808

Memory consumption after 31000 iterations is 6626824

Memory consumption after 32000 iterations is 6810832

Memory consumption after 33000 iterations is 7256976

Memory consumption after 34000 iterations is 7440984

Memory consumption after 35000 iterations is 7625000

Memory consumption after 36000 iterations is 7809000

Memory consumption after 37000 iterations is 7993008

Memory consumption after 38000 iterations is 8177016

Memory consumption after 39000 iterations is 8361016

Memory consumption after 40000 iterations is 8545032

Memory consumption after 41000 iterations is 8729040

Memory consumption after 42000 iterations is 8913048

Memory consumption after 43000 iterations is 9097048

Memory consumption after 44000 iterations is 9281064

Memory consumption after 45000 iterations is 9465072

Memory consumption after 46000 iterations is 9649072

Memory consumption after 47000 iterations is 9833080

Memory consumption after 48000 iterations is 10017096

Memory consumption after 49000 iterations is 10201096

Memory consumption after 50000 iterations is 10385104

Memory consumption after 51000 iterations is 10569112

Memory consumption after 52000 iterations is 10753128

Memory consumption after 53000 iterations is 10937128

Memory consumption after 54000 iterations is 11121136

Memory consumption after 55000 iterations is 11305144

Memory consumption after 56000 iterations is 11489144

Memory consumption after 57000 iterations is 11673160

Memory consumption after 58000 iterations is 11857168

Memory consumption after 59000 iterations is 12041168

Memory consumption after 60000 iterations is 12225176

Memory consumption after 61000 iterations is 12409192

Memory consumption after 62000 iterations is 12593200

Memory consumption after 63000 iterations is 12777200

Memory consumption after 64000 iterations is 12961208

Memory consumption after 65000 iterations is 13145224

Memory consumption after 66000 iterations is 13853512

Memory consumption after 67000 iterations is 14037520

Memory consumption after 68000 iterations is 14221528

Memory consumption after 69000 iterations is 14405528

Memory consumption after 70000 iterations is 14589544

Memory consumption after 71000 iterations is 14773552

Memory consumption after 72000 iterations is 14957560

Memory consumption after 73000 iterations is 15141560

Memory consumption after 74000 iterations is 15325576

Memory consumption after 75000 iterations is 15509584

Memory consumption after 76000 iterations is 15693584

Memory consumption after 77000 iterations is 15877592

Memory consumption after 78000 iterations is 16061608

Memory consumption after 79000 iterations is 16245616

Memory consumption after 80000 iterations is 16429616

Memory consumption after 81000 iterations is 16613624

Memory consumption after 82000 iterations is 16797640

Memory consumption after 83000 iterations is 16981640

Memory consumption after 84000 iterations is 17165648

Memory consumption after 85000 iterations is 17349656

Memory consumption after 86000 iterations is 17533656

Memory consumption after 87000 iterations is 17717672

Memory consumption after 88000 iterations is 17901680

Memory consumption after 89000 iterations is 18085688

Memory consumption after 90000 iterations is 18269688

Memory consumption after 91000 iterations is 18453704

Memory consumption after 92000 iterations is 18637712

Memory consumption after 93000 iterations is 18821712

Memory consumption after 94000 iterations is 19005720

Memory consumption after 95000 iterations is 19189736

Memory consumption after 96000 iterations is 19373736

Memory consumption after 97000 iterations is 19557744

Memory consumption after 98000 iterations is 19741752

Memory consumption after 99000 iterations is 19925768

Memory consumption after 100000 iterations is 20109768














Reproduced on:
 - Debian Lenny (dotdeb): PHP 5.3.2
 - Fastcgi & CLI
 - With and without xcache
 - amd64 architecture
 [2010-03-20 12:59 UTC] mat999 at gmail dot com
-PHP Version: 5.3.1 +PHP Version: 5.3.2
 [2010-03-20 12:59 UTC] mat999 at gmail dot com
Can this be reopened?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC