6
I was one day doing some tests, analyzing how functions influence memory usage, and, by chance, called the function ob_get_clean()
.
I noticed that the function call "decreased" the memory size used by php.
With ob_start()
I noticed earlier that the use of memory increased, as expected, because it stores the output in a buffer.
Now I don’t understand why ob_get_clean()
"cleaned" some value of buffer, decreasing memory, and ob_start()
was not called anywhere in the code.
Below follows the results I obtained:
<?php
echo memory_get_usage(); //122224
?>
<?php
ob_get_clean();
echo memory_get_usage(); //113992
?>
Does anyone know why when calling ob_get_clean()
memory has diminished?
Is there any configuration in php.ini that starts the buffer automatically or something like that?
The directive
ob_implicit_flush
is disabled? If yes, it may be that PHP is saving the output in memory to, only at the end, cause the buffer to be released from memory.– Rodrigo Rigotti
Would not be
implicit_flush
? I found this line in my php.iniimplicit_flush = Off
. Is disabled.– Wallace Maxters
I just took the test by changing this directive to "On". I got different results, but when I use
ob_end_clean
continues to "decrease" memory usage. withoutob_end_clean = 121808
and withob_end_clean = 113576
– Wallace Maxters