The actual effect of PHP's unset () function _php Tutorial

Source: Internet
Author: User

The actual effect of PHP's unset () function

It's highly recommended that you share this technical article

PHP variable to memory overhead and release, whether Unset () really frees memory. Turn from: The actual effect of PHP's unset () function
The test code is as follows: copy PHP content to clipboard

PHP Code:

For ($i= 1; $i< -; $i++ ) {
$str= str_repeat(' 01234567 ', $i);
$a= Memory_get_usage();
Unset ($str);
$b= Memory_get_usage();
Echo"n
"
.$i.': '. ($b- $a).' Bytes. ';
}

It turns out that 8 x 32 = 256 is really necessary to release memory when it is 256 bytes long, and some people say that it is not as fast as direct $STR = null.
Here are the actual results:
The results are as follows:
1:0 Bytes.
2:0 Bytes.
3:0 Bytes.
4:0 Bytes.
5:0 Bytes.
6:0 Bytes.
7:0 Bytes.
8:0 Bytes.
9:0 Bytes.
10:0 Bytes.
11:0 Bytes.
12:0 Bytes.
13:0 Bytes.
14:0 Bytes.
15:0 Bytes.
16:0 Bytes.
17:0 Bytes.
18:0 Bytes.
19:0 Bytes.
20:0 Bytes.
21:0 Bytes.
22:0 Bytes.
23:0 Bytes.
24:0 Bytes.
25:0 Bytes.
26:0 Bytes.
27:0 Bytes.
28:0 Bytes.
29:0 Bytes.
30:0 Bytes.
31:0 Bytes.
: -272 Bytes.
: -280 Bytes.
Bytes: -288.
: -296 Bytes.
Bytes: -304.
Panax Notoginseng: -312 Bytes.
: -320 Bytes.
: -328 Bytes.
Max: -336 Bytes.
In: -344 Bytes.
: -352 Bytes.
Bytes: -360.
: -368 Bytes.
: -376 Bytes.
Bytes: -384.
Bytes: -392.
Bytes: -400.
$ -408 Bytes.
: -416 Bytes.
Wuyi: -424 Bytes.
Bytes: -432.
: -440 Bytes.
Wu: -448 Bytes.
: -456 Bytes.
Bytes: -464.
£ º -472 Bytes.
: -480 Bytes.
Bytes: -488.
: -496 Bytes.
Bytes: -504.
: -512 Bytes.
: -520 Bytes.
: -528 Bytes.
: -536 Bytes.
: -544 Bytes.
Bytes: -552.
Bytes: -560.
Bytes: -568.
: -576 Bytes.
Bytes: -584.
Bytes: -592.
: -600 Bytes.
Bytes: -608.
Bytes: -616.
Bytes: -624.
Bytes: -632.
: -640 Bytes.
Bytes: -648.
Bytes: -656.
Bayi: -664 Bytes.
Bytes: -672.
Bytes: -680.
Bytes: -688.
Bytes: -696.
Bytes: -704.
: -712 Bytes.
: -720 Bytes.
Bytes: -728.
: -736 Bytes.
Bytes: -744.
: -752 Bytes.
Bytes: -760.
94: -768 Bytes.
Bytes: -776.
: -784 Bytes.
$ -792 Bytes.
98: -800 Bytes.
: -808 Bytes.

http://www.bkjia.com/PHPjc/445562.html www.bkjia.com true http://www.bkjia.com/PHPjc/445562.html techarticle The actual effect of PHP's unset () function is strongly recommended to share this technical article PHP variable on memory overhead and release, unset () whether or not it really frees up memory. Turn from: Php unse ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.