Bug->Req #54147 [Opn->Csd]: debug_backtrace increases memory usage

From: Date: Sat, 02 Mar 2013 18:10:52 +0000
Subject: Bug->Req #54147 [Opn->Csd]: debug_backtrace increases memory usage
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-177529@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54147&edit=1

 ID:                 54147
 Updated by:         dlsniper@php.net
 Reported by:        jacob at jacobweber dot com
 Summary:            debug_backtrace increases memory usage
-Status:             Open
+Status:             Closed
-Type:               Bug
+Type:               Feature/Change Request
 Package:            Unknown/Other Function
 Operating System:   Red Hat Linux
 PHP Version:        5.2.17
-Assigned To:        
+Assigned To:        dlsniper
 Block user comment: N
 Private report:     N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

This has been fixed as of PHP 5.3.6


Previous Comments:
------------------------------------------------------------------------
[2012-11-12 09:41:26] twin at nightmail dot ru

As you suppose, in PHP 5.3.6 option for skip args was added. And for function 
debug_print_backtrace() too.

------------------------------------------------------------------------
[2011-03-03 03:58:43] jacob at jacobweber dot com

Description:
------------
Calling debug_backtrace(false) can lead to a huge increase in memory usage, if 
it's called from within a function that was passed a huge string as an argument. 
This is because the string will be duplicated in the "args" field of the result.

It would be nice to have another boolean argument to debug_backtrace, that would 
tell it to skip the "args" field. This would be similar to the one that skips the 
"object" field.

Or could the arguments be returned as references, so they don't increase memory 
usage?

Test script:
---------------
function test($str) {
	echo "before: ".round(memory_get_usage()/1024/1024, 2)." MB\n";
	debug_backtrace(false);
	echo "after: ".round(memory_get_usage()/1024/1024, 2)." MB\n";
}
test(str_repeat('a', 10000000));


Expected result:
----------------
before: 9.59 MB
after: 9.59 MB

(This is what I get if I remove the debug_backtrace() call.)

Actual result:
--------------
before: 9.59 MB
after: 19.12 MB


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=54147&edit=1


Thread (3 messages)

« previous php.bugs (#177529) next »