Home > Backend Development > PHP Tutorial > PHP detection to obtain memory information_PHP tutorial

PHP detection to obtain memory information_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:32:32
Original
1218 people have browsed it

PHP can also detect and obtain the memory information of Windows, and the code is quite simple. I discovered it accidentally and thought it could be used in the future, so I would like to share it with you.

This code will get the total memory, initial usage and other memory information:

 01

 02echo "Initial: ".memory_get_usage()." Byte n";

 03for ($i = 0; $i < 100000; $i++) {

 04 $array []= md5($i);

 05}

 06for ($i = 0; $i < 100000; $i++) {

 07 unset($array[$i]);

 08}

 09echo "Final: ".memory_get_usage()." Byte n";

 10echo "Total memory: ".memory_get_peak_usage()." Bytes n";

 11?>

Example of running results:

Initial: 66104 bytes Final: 590600 bytes Total memory: 12591704 bytes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/755617.htmlTechArticlePHP can also detect and obtain Windows memory information, and the code is quite simple. I discovered it accidentally. I think it can be used in the future. Use it and share it with everyone here. This code will get the total memory, initial...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template