memory_get_usage

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

memory_get_usage — PHP에 할당된 메모리 양을 반환합니다.


설명

memory_get_usage(bool $real_usage = false): int

현재 PHP 스크립트에 할당된 메모리 양을 바이트 단위로 반환합니다.


매개변수

real_usage
사용하지 않은 페이지를 포함하여 시스템에서 할당된 총 메모리를 얻으려면 이것을 true로 설정하십시오. 설정되지 않거나 false인 경우 사용된 메모리만 보고됩니다.

메모: PHP는 emalloc()에 의해 할당되지 않은 메모리를 추적하지 않습니다.


반환 값

메모리 양을 바이트 단위로 반환합니다.


Examples

예제 #1 memory_get_usage() 예제

                  
<?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

?>
                  
                

기타