memory_get_peak_usage()

memory_get_peak_usage() — Returns the peak of memory allocated by PHP.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns the peak of memory, in bytes, that's been allocated to your PHP script.

Signature

memory_get_peak_usage(bool $real_usage = false): int

Parameters

ParameterTypeWhat it takes
$real_usageboolSet this to true to get the real size of memory allocated from system. If not set or false only the memory used by emalloc() is reported.

Return value

Returns the memory peak in bytes.

Example

The PHP manual ships no example for memory_get_peak_usage(); the signature and the parameter table above are the contract.

See also

memory_get_usage(), memory_reset_peak_usage()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page memory_get_peak_usage() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.