array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'function.memory-get-usage.php', 1 => 'memory_get_usage', 2 => 'Returns the amount of memory allocated to PHP', ), 'up' => array ( 0 => 'ref.info.php', 1 => 'PHP-Optionen-/-Informationen-Funktionen', ), 'prev' => array ( 0 => 'function.memory-get-peak-usage.php', 1 => 'memory_get_peak_usage', ), 'next' => array ( 0 => 'function.memory-reset-peak-usage.php', 1 => 'memory_reset_peak_usage', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/info/functions/memory-get-usage.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

memory_get_usage

(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)

memory_get_usageReturns the amount of memory allocated to PHP

Beschreibung

memory_get_usage(bool $real_usage = false): int

Returns the amount of memory, in bytes, that's currently being allocated to your PHP script.

Parameter-Liste

real_usage

Set this to true to get total memory allocated from system, including unused pages. If not set or false only the used memory is reported.

Hinweis:

PHP does not track memory that is not allocated by emalloc()

Rückgabewerte

Returns the memory amount in bytes.

Beispiele

Beispiel #1 A memory_get_usage() example

<?php
// This is only an example, the numbers below will
// differ depending on your system

echo memory_get_usage() . "\n"; // 36640

$a = str_repeat("Hello", 4242);

echo
memory_get_usage() . "\n"; // 57960

unset($a);

echo
memory_get_usage() . "\n"; // 36744

?>

Siehe auch