From:             robert dot munteanu at betbrain dot com
Operating system: Linux  2.6.8.1
PHP version:      5.0.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Memory allocated for objects created in object methods is not 
released

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 bug report at http://bugs.php.net/?id=33487&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33487&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33487&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33487&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33487&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33487&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33487&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33487&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33487&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33487&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33487&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33487&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33487&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33487&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33487&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33487&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33487&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33487&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33487&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33487&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33487&r=mysqlcfg

Reply via email to