This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Astra_Memory_Limit_Notice::get_memory_limit_in_bytes()

Get PHP memory limit in bytes


Description


Source

File: inc/class-astra-memory-limit-notice.php

	private function get_memory_limit_in_bytes() {
		$memory_limit = ini_get( 'memory_limit' );

		if ( $memory_limit == -1 ) {
			return PHP_INT_MAX; // Unlimited
		}

		// Handle edge cases where ini_get returns false or empty
		if ( false === $memory_limit || empty( $memory_limit ) ) {
			return 134217728;
		}

		$unit  = strtolower( substr( $memory_limit, -1 ) );
		$value = (int) $memory_limit;

		if ( $value <= 0 ) {
			return 134217728;
		}

		switch ( $unit ) {
			case 'g':
				$value *= 1024 * 1024 * 1024;
				break;
			case 'm':
				$value *= 1024 * 1024;
				break;
			case 'k':
				$value *= 1024;
				break;
		}

		return $value;
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.