Req #33487 [Asn->Opn]: Memory allocated for objects created in object methods is not released
| From: | kalle@php.net | Date: | Tue, 24 Oct 2017 08:13:07 +0000 |
| Subject: | Req #33487 [Asn->Opn]: Memory allocated for objects created in object methods is not released | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212240@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=33487&edit=1
ID: 33487
Updated by: kalle@php.net
Reported by: robert dot munteanu at betbrain dot com
Summary: Memory allocated for objects created in object
methods is not released
-Status: Assigned
+Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: *
-Assigned To: dmitry
+Assigned To:
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2015-05-10 04:28:29] requinix@php.net
Related To: Bug #69615
------------------------------------------------------------------------
[2014-08-27 10:00:27] nikic@php.net
In PHP 7 the object store is just a ptr array, so the overhead here reduces to sizeof(void *) *
max_number_of_objects. This should reduce the memory usage of the object store by a factor of 8 on
both 32bit and 64bit.
------------------------------------------------------------------------
[2014-08-27 06:16:48] dmitry@php.net
This is not a bug, and it's not fixed.
------------------------------------------------------------------------
[2014-08-26 18:55:41] chrisdmiddleton at gmail dot com
Has this bug been fixed in PHP 5.*?
------------------------------------------------------------------------
[2006-01-26 19:56:32] nick at mythgaming dot net
Note that the memory is freed inside php, just not yielded back to the operating system until
execution ends.
In this example, the memory is claimed as the function executes, then re-used when the function is
run again (instead of using up twice as much memory):
----------
<?php
function doNothing() {
$res = array();
for ( $i = 0; $i < 20000; $i++) {
$res[$i] = new StdClass;
}
}
// Unix only
function get_usage() {
$my_pid = getmypid();
$usage =
ps -eo%mem,rss,pid | grep $my_pid;
$kb = preg_split("/\s+/", $usage);
return sprintf("%.3f",$kb[2] / 1024) . "MB";
}
echo "Before: ".get_usage()."\n";
doNothing();
echo "One Use: ".get_usage()."\n";
doNothing();
echo "Two Uses: ".get_usage()."\n";
?>
Output
------
Before: 5.555MB
One Use: 10.164MB
Two Uses: 10.293MB
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=33487
--
Edit this bug report at https://bugs.php.net/bug.php?id=33487&edit=1