php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44636 class_exists() memory leak
Submitted: 2008-04-04 10:09 UTC Modified: 2008-04-15 07:27 UTC
From: bigtree at 29a dot nl Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.2.5 OS: FreeBSD 6.1-RELEASE-p10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bigtree at 29a dot nl
New email:
PHP Version: OS:

 

 [2008-04-04 10:09 UTC] bigtree at 29a dot nl
Description:
------------
When implicitely casting class_exists() to a boolean, a memory leak occurs. It does not matter if the given class exists or not.

Reproduce code:
---------------
for ($i = 1; $i < 100; $i++) {

    if (class_exists('foo')) { }
    echo memory_get_usage() . "\n";	
	
}


Expected result:
----------------
A constant amount of memory (at least after the first iteratation)

Actual result:
--------------
A growing amount of used memory.

A workaround can be:

if ((boolean)class_exists('foo')) { }

or

$foo = class_exists('foo');
if ($foo) {} 

in these cases the memory leak does not occur

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-12 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-04-15 07:09 UTC] bigtree at 29a dot nl
Tried this on a different machine with same OS + PHP version. The bug does not occur there. I assume a rebuild will help.
 [2008-04-15 07:27 UTC] bigtree at 29a dot nl
Disabling the Zend Optimizer actually solved the problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 12:01:30 2024 UTC