21,882
社区成员
发帖
与我相关
我的任务
分享
PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 10255856 bytes) in /usr/local/asg/www/scripts/sync.php on line 641
$arr = array();
for($i=0;$i=1590000;$i++) {
$arr[] = $i;
}
echo count($arr);
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in D:\server\www\02\array.php on line 5
$arr = array();
for($i=0;$i<1550000;$i++) {
$arr[] = $i;
}
echo count($arr);
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 512M
323904 323904
168 324072
80 324152
80 324232
80 324312
右边的减去左边的就是上个内存的使用情况
我还想问下,那个报警是想说明说明呢
Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes)
是不是从字面上来理解,允许使用的134217728字节内存已经耗尽,试图分配24个字节,也就是再分配24字节的内存就可以?$t = 0;
echo memory_get_usage() - $t, ' ',$t = memory_get_usage(), PHP_EOL;
$a = array();
echo memory_get_usage() - $t, ' ', $t = memory_get_usage(), PHP_EOL;
$a[] = 1;
echo memory_get_usage() - $t, ' ', $t = memory_get_usage(), PHP_EOL;
$a[] = 2;
echo memory_get_usage() - $t, ' ', $t = memory_get_usage(), PHP_EOL;
$a[] = 3;
echo memory_get_usage() - $t, ' ', $t = memory_get_usage(), PHP_EOL;