Welcome Guest. Please Login or Register  


You are here: Index > AMPPS > General Support > Topic : PHP OOM crash below memory limit



Threaded Mode | Print  

 PHP OOM crash below memory limit (0 Replies, Read 3267 times)
djnesh
Group: Member
Post Group: Newbie
Posts: 1
Status:
It seems that PHP memory limit has some hard memory limits set (or memory related bugs) as PHP process crashes with OOM errors long before reaching set memory_limit.

Any solutions?

OS: Windows 10 64bit / 16Gb RAM
AMPPS 4.9.3

PHP:
Code
PHP 7.0.22 (cli) (built: Aug  1 2017 14:13:55) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with the ionCube PHP Loader v10.0.0, Copyright (c) 2002-2017, by ionCube Ltd.
    with Zend OPcache v7.0.22, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans


Output:
Code
<snip>
Allocated 702.34 mb
Try 800M

VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.

PHP Fatal error:  Out of memory (allocated 2097152) (tried to allocate 838860824 bytes)


PHP:
Code
PHP 5.6.31 (cli) (built: Jul  5 2017 22:25:43)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with the ionCube PHP Loader v10.0.0, Copyright (c) 2002-2017, by ionCube Ltd.
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans


Output:
Code
<snip>
Allocated 1.27 gb
Try 1400M

PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate 1468006401 bytes)


Test script:
PHP Code

<?php <?php
ini_set
('memory_limit''4024M');

$i 0;
while(
true) {
    echo 
"Try {$i}M\n";
    
$a loadmem($i);
    echo 
"Allocated " humanize(memory_get_usage()) . PHP_EOL;
    unset(
$a);
    
$i += 100;
}

function 
loadmem($howmuchmeg)
{
    if(!
$howmuchmeg) {
        return 
'';
    }
    
$a str_repeat("0"$howmuchmeg 1024 1024);

    return 
$a;
}

function 
humanize($size)
{
    
$unit = array('b''kb''mb''gb''tb''pb');

    return 
round($size pow(1024, ($i floor(log($size1024)))), 2) . ' ' $unit[$i];


IP: --   

« Previous    Next »

Threaded Mode | Print  



Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is March 19, 2024, 5:25 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.036