Why does ob_get_clean clear the memory without starting the buffer with ob_start ()?

6

I was testing tests one day, analyzing how functions influence memory usage, and by chance I called the function ob_get_clean() . I noticed that the function call "decreased" the memory size used by php.

With ob_start() I have previously noticed that memory usage increased, as expected, because it saves the output in a buffer.

Now I do not understand why ob_get_clean() "wiped" some buffer value, decreasing memory, ob_start() was not called anywhere in the code.

Here are the results I got:

<?php
echo memory_get_usage(); //122224
?>

<?php
ob_get_clean();
echo memory_get_usage(); //113992
?>

Does anyone know why calling% w / o memory has decreased?

Is there any configuration in php.ini that automatically starts buffering or something like that?

    
asked by anonymous 26.03.2014 / 17:20

1 answer

2

Yes, there is.

In your php.ini how is the output_buffering option set?

output_buffering=On

Enable automatic output buffering.

You can disable it:

output_buffering=Off

or specify the buffer size:

output_buffering=4096

See More: Output Buffering in PHP Manual

    
27.03.2014 / 17:46