← All docs
memory_get_peak_usage()
Returns peak live native heap bytes, including block headers and allocator rounding. With real_usage=true returns the fixed heap arena capacity, including unused space. Excludes concat scratch, libc, and Rust bridge allocations.
memory_get_peak_usage()
function memory_get_peak_usage(bool $real_usage = false): int
Returns peak live native heap bytes, including block headers and allocator rounding. With real_usage=true returns the fixed heap arena capacity, including unused space. Excludes concat scratch, libc, and Rust bridge allocations.
Parameters:
$real_usage(bool), defaultfalse, optional
Returns: int
Availability
| Compiled (AOT) | Magician (eval) |
|---|---|
| Available | Available |
Examples:
memory_reset_peak_usage();
$values = array_fill(0, 10000, 1);
unset($values);
echo memory_get_peak_usage();
Internals
For how memory_get_peak_usage is implemented in the compiler, see the internals page.