How to avoid the "memory ... exhausted" error when using debug_backtrace () in a custom error handler?

I wrote an error handler for my website that looks like this:

function errorHandler($number, $string, $file, $line, $context, $type = '') {
// save stuff in DB
}

What I am registering like this:

set_error_handler('errorHandler', E_ALL);

I save all the passed variables to the DB as well as the return line to help me debug the problem:

print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT), true)

The problem is that I sometimes get this error:

The allowed memory size of 134217728 bytes has been exhausted (tried to allocate 30084081 bytes)

, , , , undefined Amazon S3 ( PHP AWS). , , Amazon AWS , , (?).

backtrace, , , debug_backtrace() - ( , )?

+4
6

, DEBUG_BACKTRACE_PROVIDE_OBJECT

, , , , .

- , ,

try{
  throw new Exception();
}catch(Exception $e){
  echo $e->getTraceAsString();
}

http://php.net/manual/en/exception.gettraceasstring.php

, , print_r ($ e- > getTrace());

http://php.net/manual/en/exception.gettrace.php

+2

, DEBUG_BACKTRACE_PROVIDE_OBJECT DEBUG_BACKTRACE_IGNORE_ARGS

http://php.net/manual/en/function.debug-backtrace.php

+2

debug_backtrace.

print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 50), true);

PHP debug_backtrace

+1

:

ini_set("memory_limit","256M");
print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT), true);
+1

, . , .

ini_set, 1gb , , .

+1

, , , var_dump print_r? var_dump , , edmondscommerce, .

+1

All Articles