#2989
Soft79
Keymaster

Another trick would be placing error_log(print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 100), true)); right before the lines that produce memory errors. For example if memory usage is high, like so if (memory_get_usage() > 100000000).

Make sure you do this only once per location per request, to prevent flooding the log.