#44636 [Opn->Fbk]: class_exists() memory leak

From: Date: Fri, 04 Apr 2008 10:16:02 +0000
Subject: #44636 [Opn->Fbk]: class_exists() memory leak
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123955@lists.php.net to get a copy of this message
ID: 44636 Updated by: felipe@php.net Reported By: bigtree at 29a dot nl -Status: Open +Status: Feedback Bug Type: Class/Object related Operating System: FreeBSD 6.1-RELEASE-p10 PHP Version: 5.2.5 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi Previous Comments: ------------------------------------------------------------------------ [2008-04-04 10:09:50] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44636&edit=1

« previous php.bugs (#123955) next »