phparraysxdebugsuhosin

Does PHP set memory limits on arrays?


I have a weird memory problem in PHP. I think something is only allowing an array to be a maximum of 0.25M. It appears the script is only using up to around 6M before it crashes.

Here's the output from xdebug:

enter image description here

Here's the function it is calling. The result of the sql query is about 800 rows of text.

public function getOptions(){
    $sql = "select Opt,
                   Code,
                   Description
            from PCAOptions";

    $result = sqlsrv_query($this->conn,$sql);

    $arrayResult = array();
    echo ini_get('memory_limit'); //this confirms that my memory limit is high enough
    while($orderObject = sqlsrv_fetch_object($result,'PCA_Option')){
        array_push($arrayResult, $orderObject);
    }
    return $arrayResult;
}

Solution

  • So, I don't know how or why this worked, but I fixed the problem by commenting out these two lines from my .htaccess file:

    #    php_value memory_limit 1024M
    #    php_value max_execution_time 18000
    

    I did this because I noticed phpinfo() was returning different values for these settings in the two columns "master" and "local".

    My php.ini had memory_limit=512M and max_execution_time=3000, whereas my .htacces file had the above values. I thought .htaccess would just override whatever was in php.ini but I guess it caused a conflict. Could this be a possible bug in php?