From:             
Operating system: Red Hat Linux
PHP version:      5.2.17
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:debug_backtrace increases memory usage

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

Reply via email to