Bug #72466 [NEW]: Memory leak

From: Date: Wed, 22 Jun 2016 07:41:13 +0000
Subject: Bug #72466 [NEW]: Memory leak
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201790@lists.php.net to get a copy of this message
From:             rusa959 at gmail dot com
Operating system: Ubuntu 16.04 LTS
PHP version:      5.6.22
Package:          *General Issues
Bug Type:         Bug
Bug description:Memory leak

Description:
------------
In php versions 7.0.6, 5.6.22, 5.6.16, 5.4.35
I have construct object that have anonymous function in his field named
"callback".
When i am trying to unset object - object is still exists, memory that
allocated to object is not released.
In php version 5.3.10 memory is released.

Test script:
---------------
<?php
class Leak
{
    protected $callback;

    public function set()
    {
        $this->callback = function(){};
    }
}
$base_usage = memory_get_usage();
for($i=0;$i<12;$i++) {
    echo 'step-1 ' . (memory_get_usage() - $base_usage) . PHP_EOL;
    $leak = new Leak();
    $leak->set();
    unset($leak);
    echo 'step-2 ' . (memory_get_usage() - $base_usage) . PHP_EOL;
}
echo 'step-3 ' . (memory_get_usage() - $base_usage) . PHP_EOL;

Expected result:
----------------
step-1 344
step-2 840
step-1 840
step-2 840
step-1 840
step-2 840
step-1 840
step-2 840
step-1 840
step-2 840
step-1 840
....

Actual result:
--------------
step-1 344
step-2 840
step-1 840
step-2 1328
step-1 1328
step-2 1816
step-1 1816
step-2 2304
step-1 2304
step-2 2792
step-1 2792
step-2 3280
....

-- 
Edit bug report at https://bugs.php.net/bug.php?id=72466&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72466&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72466&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72466&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72466&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72466&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72466&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72466&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72466&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72466&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72466&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72466&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72466&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72466&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72466&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72466&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72466&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72466&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72466&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72466&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72466&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#201790) next »