Valid memory limit test

I am having problems with a failed ION-Cube module. The module imports the csv data into our database, but if the csv file is large (15 + M), the result is an internal server error.

Support told me that there was not enough RAM on my server to run the module. The server has 1 GB of RAM installed, so I wrote a simple script test to check if ini_set is working.

<pre>
<?php 
function tryAlloc($megabyte){
    echo "try allocating {$megabyte} megabyte...";
    $dummy = str_repeat("-",1048576*$megabyte);
    echo "pass.";
    echo "Usage: " . memory_get_usage(true)/1048576; 
    echo " Peak: " . memory_get_peak_usage(true)/1048576;
    echo "\n";
}   
for($i=10;$i<1000;$i+=50){
    $limit = $i.'M';
    ini_set('memory_limit', $limit); 
    echo "set memory_limit to {$limit}\n"; 
    echo "memory limit is ". ini_get("memory_limit")."\n";
    tryAlloc($i-10);
}

?>
</pre>

It works without a problem. Are there any serious flaws in this test? We have many problems with this module, and support continues to inform us that the problem lies in our server. -.-

PS: . php.ini. . .htaccess, . . / .

+3

Source: https://habr.com/ru/post/1790941/


All Articles