From:             
Operating system: Ubuntu Natty Nerwhal
PHP version:      5.3SVN-2011-09-20 (snap)
Package:          Performance problem
Bug Type:         Bug
Bug description:possibility memory leak on namespace and spl_autoload_register

Description:
------------
Hi,

I want to report (possible) bug that related to namespace and 
spl_autoload_register.

Somehow, I cannot reclaim memory used (using unset) if I am using namespace
WITH 
include(_once) or require(_once) (on multiple page call) compared than
using 
multiple namespace on single page alone. I do not know if it is a bug or 
perfomance issue.

I met the same case on spl_autoload_register. I compared using
include(_once) or 
require(_once) against spl_autoload_register, and found the resource
(memory 
usage) cannot be claimed.

so, that's all.



Test script:
---------------
namespace Abstraction;


$start = microtime('time');
$mem = memory_get_usage();

/*
 *  Untuk sementara, penggunaan namespace TIDAK BOLEH MENGIKUTSERTAKAN
include dan require,
 *  karena hal seperti ini menggunakan memory resource sangat tinggi. Hal
ini sepertinya adalah bug (memory leak).
 *  Kejadian serupa juga dapat ditemui pada penggunaan
spl_autoload_register.
 */

abstract class RequestAbstract
{
    abstract public function server($key);
}

class RequestImpl {}

class NamespaceAbstract {}


namespace Http;

use \Abstraction;

class MyRequest extends Abstraction\RequestAbstract 
{
    public function server($key = '')
    {
        return new Request;
    }
}

class RequestConcrete extends Abstraction\RequestImpl {}
class Response {}
    
$test3 = new Response;
$test4 = new MyRequest;
$test5 = new RequestConcrete;

$test6 = new Abstraction\RequestImpl;
$test7 = new Abstraction\NamespaceAbstract;
print_r($test3);
print_r($test4);
print_r($test5);
print_r($test6);
print_r($test7);

unset($test, $test3, $test4, $test5,$test6, $test7);

echo "Elapsed: ", microtime('time') - $start, " Memory Usage: ",
memory_get_usage() - $mem;

// give result only consumed 156 bytes (compared than using include or
require)

Expected result:
----------------
Test script on singlepage namespace:
// give result only consumed 156 bytes (compared than using include or
require)

Test script on multiplepage namespae:
Expected: 156 bytes

Actual result:
--------------
Test script on singlepage namespace:
// give result only consumed 156 bytes (compared than using include or
require)

Test script on multiplepage namespae:
Actual: 1 KB (more or less)

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

Reply via email to