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

Simple example of displaying and releasing memory in php

WBOY
Release: 2016-07-25 08:57:17
Original
1064 people have browsed it
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
?>
Copy after login


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template