|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14263 Don't free each allocation during shutdown
Submitted: 2001-11-28 04:00 UTC Modified: 2015-02-17 09:20 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: Assigned:
Status: Wont fix Package: CGI/CLI related
PHP Version: * OS: *
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.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2001-11-28 04:00 UTC]
If compiled in standalone cgi mode, when the script exits, php only needs to free resources, not other arrays or strings or items (unless we ever support object destructors).

It can take a LONG time to free a hundred thousand or so elements in nested arrays, 4 or 5 times longer than it takes to create then.

See these threads in phpdev mailing list:
Re: [PHP-DEV] maybe serious error in RC3 memory manager
RE: [PHP-DEV] CGI quick cleanup

Sample code:
Note how long it takes to exit after finishing.

#! /usr/bin/php -q


class thingy {
   function thingy($c) {
     if ($c>0) $this->ref=&new thingy($c-1);



for($i=0;$i<$max;$i++) {
   $stash[$r][]=&new thingy(rand(0,10));
   echo "\rUse: ".floor($i/$max*100)."% ";
echo "\n";


foreach(array_keys($stash) as $key) {
   echo "\rFree: ".floor($c/$max*100)."% ";
echo "\n";


print "Use: ".($mid-$start)."\n";
print "Free: ".($done-$mid)."\n";



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-28 04:01 UTC]
Making it a feature request, as it's not a "bug".
 [2010-12-17 14:19 UTC]
-Summary: Don't free each allocation in cgimode +Summary: Don't free each allocation during shutdown -Package: Feature/Change Request +Package: CGI related -Operating System: all +Operating System: * -PHP Version: 4.0.6 +PHP Version: *
 [2015-02-17 09:18 UTC]
-Status: Open +Status: Wont fix
 [2015-02-17 09:18 UTC]
This is simply not feasible today.

I can be wrong, but even so this kind of change would require an RFC.

I'm going to mark the bug as won't fix, this report can still be found by any future RFC.
 [2015-02-17 09:20 UTC]
Sorry about the wait :)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu May 06 21:01:24 2021 UTC