php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55739 possibility memory leak on namespace and spl_autoload_register
Submitted: 2011-09-20 12:39 UTC Modified: 2016-12-17 15:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: support at freelancecode dot cz dot cc Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.3SVN-2011-09-20 (snap) OS: Ubuntu Natty Nerwhal
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 - 26 = ?
Subscribe to this entry?

 
 [2011-09-20 12:39 UTC] support at freelancecode dot cz dot cc
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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-17 15:21 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2016-12-17 15:21 UTC] nikic@php.net
Very unlikely to be a leak, given the numbers mentioned (1KB differences are noise).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 08:01:30 2024 UTC