- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/site_checker.php
- Класс: CSiteCheckerTest
- Вызов: CSiteCheckerTest::check_memory_limit
function check_memory_limit()
{
$total_steps = 5;
if (!$this->arTestVars['last_value'])
{
$last_success = 0;
$max = 16;
$step = 1;
}
else
{
if (!CheckSerializedData($this->arTestVars['last_value']))
return false;
list($last_success, $max, $step) = unserialize($this->arTestVars['last_value'], ['allowed_classes' => false]);
}
$strRequest = "GET "."/bitrix/admin/site_checker.php?test_type=memory_test&unique_id=".checker_get_unique_id()."&max=".($max - 1)." HTTP/1.1rn";
$strRequest.= "Host: ".$this->host."rn";
$strRequest.= "rn";
if (!$res = $this->ConnectToHost())
return false;
if (IsHttpResponseSuccess($res, $strRequest))
{
$last_success = $max;
$max *= 2;
}
else
$max = floor(($last_success + $max) / 2);
if ($max < 16)
return false;
if ($step < $total_steps)
{
$this->test_percent = floor(100 / $total_steps * $step);
$step++;
$this->arTestVars['last_value'] = serialize(array($last_success, $max, $step));
return true;
}
$ok = false;
$res = GetMessage('SC_NOT_LESS',array('#VAL#' => $last_success));
$last_success = (int)$last_success;
if ($last_success > 32)
{
$ok = true;
$cur = BitrixMainConfigIni::getInt('memory_limit');
if ($cur > 0 && $cur < $last_success * 1024 * 1024)
{
$res .= '
'.GetMessage('SC_MEMORY_CHANGED', array('#VAL0#' => ini_get('memory_limit'), '#VAL1#' => '512M'));
$ok = null;
}
}
return $this->Result($ok, $res);
}