granGripau Posted October 12, 2009 Share Posted October 12, 2009 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 More sharing options...
pastcow Posted October 12, 2009 Share Posted October 12, 2009 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) Link to comment https://forums.phpfreaks.com/topic/177439-output-buffering-question/#findComment-935576 Share on other sites More sharing options...
granGripau Posted October 12, 2009 Author Share Posted October 12, 2009 Ok, thanks pastcow! So output buffering doesn't negatively affect cpu usage or network resources as long as there isn't more data than the memory limit? Link to comment https://forums.phpfreaks.com/topic/177439-output-buffering-question/#findComment-935640 Share on other sites More sharing options...
pastcow Posted October 12, 2009 Share Posted October 12, 2009 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. Link to comment https://forums.phpfreaks.com/topic/177439-output-buffering-question/#findComment-935760 Share on other sites More sharing options...
granGripau Posted October 13, 2009 Author Share Posted October 13, 2009 Wow- that's exactly what I was looking for! Thanks! Link to comment https://forums.phpfreaks.com/topic/177439-output-buffering-question/#findComment-936198 Share on other sites More sharing options...
Mark Baker Posted October 13, 2009 Share Posted October 13, 2009 So it looks like its more efficent to use buffering but it comes at the cost of increased memory usage.So buffering (for this instance) is nearly twice as fast, but at over 100 times the memory requirement, that's a big overhead. Link to comment https://forums.phpfreaks.com/topic/177439-output-buffering-question/#findComment-936203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.