Jump to content

Output Buffering question


granGripau

Recommended Posts

Hi all,

 

I've been trying to wrap my head around output buffering. So far I've found tons of benifits but I'm wondering about the downside of output buffering. Problems it creates, whether or not it increases cpu usage, does it hog network resources, etc?

 

Any info would be great...

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/177439-output-buffering-question/
Share on other sites

One downside is that when you use output buffering the contents of the page is not sent to the browser until all the PHP code inside the buffering has finished running.

 

The second thing (which im not quite sure about) is depending on how big your page is all the page output would have to be able to be stored within memory - if your page contains more data than the memory limit in php then this could be a potential problem. Without output buffering you probably wouldn't have this issue. (someone please correct me if im wrong)

Ok - i wasnt sure so ive run some benchmarks - this is the time taken to print the numbers 0-5000000, memory usage measured in bytes

 

With buffering

 

Time: 2.5493578910828

Memory: 68439492

 

Without buffering

 

Time: 4.5620698928833

Memory: 659616

 

So it looks like its more efficent to use buffering but it comes at the cost of increased memory usage.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.