Home >Backend Development >PHP Tutorial >Simple example of displaying and releasing memory in php

Simple example of displaying and releasing memory in php

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:57:171110browse
Introducing an example of displaying and releasing memory in PHP. It is very simple. It mainly focuses on the usage of the memory_get_usage() function.

Code:

<?php
//显示与释放内存
//以下数字取决于linux系统类型与版本
 
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
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn