php.net |  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
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: samjam@php.net Assigned:
Status: Wont fix Package: CGI/CLI related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
28 + 47 = ?
Subscribe to this entry?

 
 [2001-11-28 04:00 UTC] samjam@php.net
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
<?php

ini_Set("max_execution_time","0");
ini_Set("memory_limit","500M");

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

$stash=array();
$max=500000;

$start=time();

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

$mid=time();

$max=count($stash);
$c=0;
foreach(array_keys($stash) as $key) {
   unset($stash[$key]);
   $c++;
   echo "\rFree: ".floor($c/$max*100)."% ";
}
unset($stash);
echo "\n";

$done=time();

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


?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-28 04:01 UTC] derick@php.net
Making it a feature request, as it's not a "bug".
 [2010-12-17 14:19 UTC] jani@php.net
-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] krakjoe@php.net
-Status: Open +Status: Wont fix
 [2015-02-17 09:18 UTC] krakjoe@php.net
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] krakjoe@php.net
Sorry about the wait :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC