#33487 [Opn->Asn]: Memory allocated for objects created in object methods is not released

From: Date: Mon, 27 Jun 2005 10:17:21 +0000
Subject: #33487 [Opn->Asn]: 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-81067@lists.php.net to get a copy of this message
 ID:               33487
 Updated by:       sniper@php.net
 Reported By:      robert dot munteanu at betbrain dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Scripting Engine problem
-Operating System: Linux  2.6.8.1
+Operating System: *
-PHP Version:      5.0.4
+PHP Version:      5CVS-2005-06-27
-Assigned To:      
+Assigned To:      dmitry
 New Comment:

Dmitry, is there any way to fix this..? (btw. unset() does NOT free all
the memory..but that's, AFAIK, by design)



Previous Comments:
------------------------------------------------------------------------

[2005-06-27 11:31:02] robert dot munteanu at betbrain dot com

Description:
------------
Whenever you create an object in a method, memory is not released when
the method execution ends, unset() must be called manually.

This becomes a problem when you have long-running scripts, which
perform actions repeatedly which leads to the script running out of
memory.

Reproduce code:
---------------
<?php
class Tester {
    public function doNothing() {
        $res = array();
        for ( $i = 0; $i < 10000; $i++) {
            $res[$i] = new StdClass;
        }
    }
}

$t = new Tester();
echo "Before: ".memory_get_usage()."\n";
$t->doNothing();
echo "After: ".memory_get_usage()."\n";
?>


Expected result:
----------------
Memory usage remains roughly the same.

Actual result:
--------------
Before: 41424
After: 432560



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33487&edit=1


Thread (10 messages)

« previous php.bugs (#81067) next »