‪TYPO3CMS  9.5
MemoryUtility.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
20 
27 {
28  private const ‪MINIMAL_PERCENT_OF_FREE_MEMORY = 0.30;
29 
38  public static function ‪isMemoryConsumptionTooHigh(): bool
39  {
40  $iniLimit = ini_get('memory_limit');
41  $memoryLimit = $iniLimit === '-1' ? -1 : GeneralUtility::getBytesFromSizeMeasurement($iniLimit);
42  $freeMemory = $memoryLimit - memory_get_usage(true);
43 
44  return $memoryLimit > 0 && $freeMemory < (self::MINIMAL_PERCENT_OF_FREE_MEMORY * $memoryLimit);
45  }
46 }
‪TYPO3\CMS\Adminpanel\Utility
Definition: MemoryUtility.php:4
‪TYPO3\CMS\Adminpanel\Utility\MemoryUtility\MINIMAL_PERCENT_OF_FREE_MEMORY
‪const MINIMAL_PERCENT_OF_FREE_MEMORY
Definition: MemoryUtility.php:28
‪TYPO3\CMS\Adminpanel\Utility\MemoryUtility\isMemoryConsumptionTooHigh
‪static bool isMemoryConsumptionTooHigh()
Definition: MemoryUtility.php:38
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Adminpanel\Utility\MemoryUtility
Definition: MemoryUtility.php:27