PHP致命错误:允许的内存大小为2097152字节已用尽

Posted

技术标签:

【中文标题】PHP致命错误:允许的内存大小为2097152字节已用尽【英文标题】:PHP Fatal error: Allowed memory size of 2097152 bytes exhausted 【发布时间】:2018-05-19 09:57:24 【问题描述】:

在运行 Apache 2.4 和 php 7.0.22 的 Ubuntu 16.04 上运行 WordPress 网站的开发服务器上开始出现此问题。我尝试安装新的 WP 站点并创建一个 phpinfo() 文档,memory_limit 显示为 4096M。当我尝试加载新网站时,我在日志中收到 500 错误:

[Tue Dec 05 11:31:21.361553 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP Fatal error:  Allowed memory size of 2097152 bytes exhausted (tried to allocate 110592 bytes) in /backup/storage/sites/wp.webtent.org/wp-settings.php on line 116
[Tue Dec 05 11:31:21.361597 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP Stack trace:
[Tue Dec 05 11:31:21.361610 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP   1. main() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:0
[Tue Dec 05 11:31:21.361621 2017] [:error] [pid 339] [client 192.168.1.112:60842] PHP   2. require() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:33

这是顶部的快照,看起来不像是内存问题...

top - 11:48:45 up 55 min,  2 users,  load average: 0.11, 0.10, 0.18
Tasks: 301 total,   1 running, 300 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.7 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8219672 total,  5059996 free,   802632 used,  2357044 buff/cache
KiB Swap:  4095996 total,  4059280 free,    36716 used.  7306804 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1523 mysql     20   0  551784 159588  15356 S   0.0  1.9   0:01.71 mysqld
 3215 robert    20   0  315180 118948  59092 S   0.0  1.4   0:17.95 compiz
 1716 root      20   0  170716  82768  43328 S   0.0  1.0   0:13.80 Xorg
 3608 robert    20   0  238364  61804  34528 S   0.0  0.8   0:00.25 evolution-alarm
 3073 robert    20   0  175796  61280  36024 S   0.0  0.7   0:00.29 hud-service
 3503 robert    20   0  227640  55264  48908 S   0.0  0.7   0:01.28 nautilus
 3246 robert    20   0  228908  54696  24776 S   0.0  0.7   0:00.13 goa-daemon
 3282 robert    20   0  165504  43108  19348 S   0.0  0.5   0:00.17 evolution-calen
 3345 robert    20   0  159160  37432  10820 S   0.0  0.5   0:00.12 evolution-calen
 3362 robert    20   0  149348  37104  10580 S   0.0  0.5   0:00.12 evolution-calen
 3599 robert    20   0  123568  34508  27464 S   0.0  0.4   0:02.82 gnome-terminal-
  310 root      20   0  139564  31700  25328 S   0.0  0.4   0:00.05 apache2
 3600 robert    20   0  111416  30300  26900 S   0.0  0.4   0:00.17 nm-applet
<snip>

这是 PHP Xdebug 跟踪的样子:

TRACE START [2017-12-05 16:31:21]
    0.0022     351672  +351672   -> main() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:0
    0.0023     351672       +0     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:15
    0.0023     351704      +32     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:20
    0.0023     351736      +32     -> error_reporting() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:27
    0.0023     352064     +328     -> dirname() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0023     352144      +80     -> dirname() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0024     352120      -24     -> define() /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:30
    0.0044     352712     +592     -> require(/backup/storage/sites/wp.webtent.org/wp-settings.php) /backup/storage/sites/wp.webtent.org/wp-admin/setup-config.php:33
    0.0044     352712       +0       -> define() /backup/storage/sites/wp.webtent.org/wp-settings.php:16
    0.0079     352992     +280       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/load.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:19
    0.0087     353088      +96       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:20
    0.0099     353184      +96       -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/plugin.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:21
    0.0099     353184       +0         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/plugin.php:25
    0.0108     354648    +1464         -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-hook.php) /backup/storage/sites/wp.webtent.org/wp-includes/plugin.php:25
    0.0109     354776     +128       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/version.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:29
    0.0109     354632     -144       -> wp_initial_constants() /backup/storage/sites/wp.webtent.org/wp-settings.php:41
    0.0109     354632       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:26
    0.0109     354664      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:27
    0.0109     354696      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:28
    0.0109     354728      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:29
    0.0109     354760      +32         -> ini_get() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:32
    0.0109     354784      +24         -> wp_convert_hr_to_bytes() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:33
    0.0110     354784       +0           -> trim() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0110     354784       +0           -> strtolower() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0110     354808      +24           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1000
    0.0110     354808       +0           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1002
    0.0110     354808       +0           -> min() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1009
    0.0110     354784      -24         -> wp_is_ini_value_changeable() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:37
    0.0110     355080     +296           -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1030
    0.0111     355080       +0           -> ini_get_all() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1031
    0.0114     486352  +131272         -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:39
    0.0114     486352       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:42
    0.0114     486384      +32         -> wp_is_ini_value_changeable() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:47
    0.0114     486384       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:50
    0.0114     486440      +56         -> wp_convert_hr_to_bytes() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:57
    0.0114     486440       +0           -> trim() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0114     486440       +0           -> strtolower() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:997
    0.0115     486464      +24           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1000
    0.0115     486464       +0           -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1002
    0.0115     486464       +0           -> min() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:1009
    0.0115     486504      +40         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:66
    0.0115     486536      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:70
    0.0115     486568      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:75
    0.0115     486600      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:79
    0.0115     486632      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:82
    0.0115     486640       +8         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:88
    0.0115     486640       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:93
    0.0116     486672      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:100
    0.0116     486704      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:103
    0.0116     486736      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:106
    0.0116     486768      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:121
    0.0116     486800      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:122
    0.0116     486832      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:123
    0.0116     486864      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:124
    0.0116     486896      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:125
    0.0116     486928      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/default-constants.php:126
    0.0116     486936       +8       -> wp_check_php_mysql_versions() /backup/storage/sites/wp.webtent.org/wp-settings.php:44
    0.0117     486936       +0         -> phpversion() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:123
    0.0117     486976      +40         -> version_compare() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:125
    0.0117     486976       +0         -> extension_loaded() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:135
    0.0117     486976       +0         -> extension_loaded() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:135
    0.0117     486936      -40       -> ini_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:47
    0.0117     486936       +0       -> ini_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:48
    0.0117     486936       +0       -> date_default_timezone_set() /backup/storage/sites/wp.webtent.org/wp-settings.php:51
    0.0117     486944       +8       -> wp_unregister_GLOBALS() /backup/storage/sites/wp.webtent.org/wp-settings.php:54
    0.0118     486944       +0         -> ini_get() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:30
    0.0118     486944       +0       -> wp_fix_server_vars() /backup/storage/sites/wp.webtent.org/wp-settings.php:57
    0.0118     486968      +24         -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:63
    0.0118     487912     +944         -> preg_match() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:66
    0.0119     487912       +0         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:96
    0.0119     487912       +0         -> strpos() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:100
    0.0119     487912       +0       -> wp_favicon_request() /backup/storage/sites/wp.webtent.org/wp-settings.php:60
    0.0119     487912       +0       -> wp_maintenance() /backup/storage/sites/wp.webtent.org/wp-settings.php:63
    0.0119     487992      +80         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:176
    0.0119     487912      -80       -> timer_start() /backup/storage/sites/wp.webtent.org/wp-settings.php:66
    0.0119     487936      +24         -> microtime() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:243
    0.0119     487936       +0       -> wp_debug_mode() /backup/storage/sites/wp.webtent.org/wp-settings.php:69
    0.0120     487936       +0         -> apply_filters() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:316
    0.0120     487936       +0         -> error_reporting() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:333
    0.0120     487960      +24         -> ini_set() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:337
    0.0120     487984      +24       -> wp_set_lang_dir() /backup/storage/sites/wp.webtent.org/wp-settings.php:93
    0.0120     488064      +80         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:356
    0.0120     488064       +0         -> is_dir() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:356
    0.0120     488064       +0         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:364
    0.0120     488096      +32         -> define() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:367
    0.0130     488616     +520       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/compat.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:96
    0.0130     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:10
    0.0130     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:44
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:134
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:219
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:278
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:291
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:323
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:361
    0.0131     488616       +0         -> interface_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:417
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:434
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:438
    0.0131     488616       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/compat.php:497
    0.0136     489640    +1024       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-list-util.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:97
    0.0240     555256   +65616       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/functions.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:98
    0.0275     555504     +248         -> require(/backup/storage/sites/wp.webtent.org/wp-includes/option.php) /backup/storage/sites/wp.webtent.org/wp-includes/functions.php:8
    0.0277     555944     +440       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-matchesmapregex.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:99
    0.0294     557080    +1136       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:100
    0.0297     557880     +800       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/class-wp-error.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:101
    0.0306     624208   +66328       -> require(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php) /backup/storage/sites/wp.webtent.org/wp-settings.php:102
    0.0306     624208       +0         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:10
    0.0314     626112    +1904         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:10
    0.0314     626112       +0           -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:10
    0.0321     627992    +1880           -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/plural-forms.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:10
    0.0321     627824     -168           -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:11
    0.0324     628904    +1080           -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/entry.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:11
    0.0324     628904       +0             -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/entry.php:10
    0.0324     628736     -168           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:13
    0.0324     629664     +928           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/translations.php:278
    0.0325     629488     -176         -> dirname() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:11
    0.0331     631600    +2112         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php) /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:11
    0.0331     631600       +0           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:11
    0.0331     631600       +0           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:137
    0.0331     632528     +928           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:207
    0.0332     633232     +704           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:270
    0.0332     634176     +944           -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/streams.php:295
    0.0332     634944     +768         -> class_exists() /backup/storage/sites/wp.webtent.org/wp-includes/pomo/mo.php:13
    0.0332     635272     +328       -> require_wp_db() /backup/storage/sites/wp.webtent.org/wp-settings.php:106
    0.0390     642704    +7432         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php) /backup/storage/sites/wp.webtent.org/wp-includes/load.php:396
    0.0390     642704       +0           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:15
    0.0390     642736      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:20
    0.0390     642768      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:21
    0.0390     642800      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:26
    0.0390     642832      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:31
    0.0391     642864      +32           -> define() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:36
    0.0391     642808      -56         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:397
    0.0391     643752     +944         -> wpdb->__construct() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:404
    0.0391     644024     +272           -> register_shutdown_function() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:568
    0.0391     644320     +296           -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:579
    0.0392     644320       +0           -> phpversion() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:582
    0.0392     644360      +40           -> version_compare() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:582
    0.0392     644320      -40       -> wp_set_wpdb_vars() /backup/storage/sites/wp.webtent.org/wp-settings.php:110
    0.0392     644648     +328         -> wpdb->__isset() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:421
    0.0392     644624      -24         -> wpdb->set_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:432
    0.0392     644624       +0           -> preg_match() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:862
    0.0393     644624       +0           -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:865
    0.0393     644624       +0           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:873
    0.0393     644624       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:978
    0.0393     644624       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0393     644624       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0393     644624       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0393     645120     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0394     645416     +296             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0394     644680     -736           -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:876
    0.0394     644680       +0           -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:879
    0.0394     644680       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0394     644680       +0           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:881
    0.0394     644680       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0394     644680       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0394     644680       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0394     645176     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645696     +520             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645728      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645752      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0395     645776      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645808      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645832      +24             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645864      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0471     645904      +40             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0472     645936      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0472     644976     -960           -> wpdb->tables() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:884
    0.0472     644976       +0             -> wpdb->get_blog_prefix() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:994
    0.0472     644976       +0               -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:926
    0.0472     644976       +0             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:996
    0.0472     645472     +496             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645776     +304             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645808      +32             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:998
    0.0473     645376     -432           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     645376       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0473     647224    +1848           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     647224       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0473     647232       +8           -> wpdb->__set() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:885
    0.0473     647232       +0             -> in_array() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:642
    0.0474     646936     -296         -> is_wp_error() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:434
    0.0474     646936       +0       -> wp_start_object_cache() /backup/storage/sites/wp.webtent.org/wp-settings.php:113
    0.0474     646936       +0         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:480
    0.0474     647032      +96         -> file_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:481
    0.0474     646936      -96         -> wp_using_ext_object_cache() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:504
    0.0485     648424    +1488         -> require_once(/backup/storage/sites/wp.webtent.org/wp-includes/cache.php) /backup/storage/sites/wp.webtent.org/wp-includes/load.php:505
    0.0485     648256     -168         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:515
    0.0485     648256       +0         -> wp_cache_init() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:516
    0.0485     648416     +160           -> WP_Object_Cache->__construct() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:153
    0.0485     648416       +0             -> is_multisite() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:709
    0.0486     648688     +272             -> register_shutdown_function() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:717
    0.0486     648712      +24         -> function_exists() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:519
    0.0486     648712       +0         -> wp_cache_add_global_groups() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:520
    0.0486     648736      +24           -> WP_Object_Cache->add_global_groups() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:233
    0.0486     648736       +0             -> array_fill_keys() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:428
    0.0486     649232     +496             -> array_merge() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:429
    0.0486     649232       +0         -> wp_cache_add_non_persistent_groups() /backup/storage/sites/wp.webtent.org/wp-includes/load.php:521
    0.0498    1023056  +373824       -> wpdb->__destruct() /backup/storage/sites/wp.webtent.org/wp-includes/wp-db.php:0
    0.0498    1023056       +0       -> WP_Object_Cache->__destruct() /backup/storage/sites/wp.webtent.org/wp-includes/cache.php:0
    0.0500     374368
TRACE END   [2017-12-05 16:31:21]

我对 Xdebug 没有任何经验,这告诉我什么?

【问题讨论】:

【参考方案1】:

你可以在这里看到http://prntscr.com/agxrtt

所以将 ini_set('Memory_limit','-1') 改为 ini_set('memory_limit',256) 或 ini_set('memory_limit','-1')

【讨论】:

是的,这是我设置 -1 无限制的解决方法。为什么有必要这样做?

以上是关于PHP致命错误:允许的内存大小为2097152字节已用尽的主要内容,如果未能解决你的问题,请参考以下文章

PHP致命错误:允许的内存大小为134217728字节已用尽

php - 致命错误:允许的内存大小为 134217728 字节已用尽 [重复]

Composer 要求内存不足。 PHP致命错误:允许的内存大小为1610612736字节已用尽

Composer 要求内存不足。 PHP 致命错误:允许的内存大小为 1610612736 字节已用完 Voyager

第二个laravel项目(v5.4)PHP致命错误:允许的内存大小为134217728字节已用尽(试图分配262144字节)

CakePHP:致命错误:允许的内存大小为 536870912 字节已用尽(尝试分配 52 字节)