Beispiel #1
0
	function setUp() {
		$this->origMemLimit = ini_get('memory_limit');
		$this->origTimeLimit = ini_get('max_execution_time');
		$this->origMemLimitMax = get_increase_memory_limit_max();
		$this->origTimeLimitMax = get_increase_time_limit_max();
		set_increase_memory_limit_max(-1);
		set_increase_time_limit_max(-1);
	}
Beispiel #2
0
/**
 * Increase the memory limit to the given level if it's currently too low.
 * Only increases up to the maximum defined in {@link set_increase_memory_limit_max()},
 * and defaults to the 'memory_limit' setting in the PHP configuration.
 * 
 * @param A memory limit string, such as "64M".  If omitted, unlimited memory will be set.
 * @return Boolean TRUE indicates a successful change, FALSE a denied change.
 */
function increase_memory_limit_to($memoryLimit = -1)
{
    $curLimit = ini_get('memory_limit');
    // Can't go higher than infinite
    if ($curLimit == -1) {
        return true;
    }
    // Check hard maximums
    $max = get_increase_memory_limit_max();
    if ($max != -1 && translate_memstring($memoryLimit) > translate_memstring($max)) {
        return false;
    }
    // Increase the memory limit if it's too low
    if ($memoryLimit == -1 || translate_memstring($memoryLimit) > translate_memstring($curLimit)) {
        ini_set('memory_limit', $memoryLimit);
    }
    return true;
}