Headers already sent error

I am seeing an error in apache logs that I haven’t been able to identify.
The error shows in apache error log but not in yii logs
I haven’t been able to replicate it I just see it in the logs.
It happens in many urls, is not specific to any particular controller or action
It seems to be linked to throwing exceptions
There are no echo calls in any controller or model
Yii version is

This is how the error looks (removed mentions specifici to site name and path)

AH01071: Got error ‘PHP message: An Error occurred while handling another error:\nyii\web\HeadersAlreadySentException: Headers already sent. in /var/www/[path_to_site_folder]/vendor/yiisoft/yii2/web/Response.php:366\nStack trace:\n#0 /var/www/[path_to_site_folder]/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()\n#1 /var/www/[path_to_site_folder]/components/Response.php(14): yii\web\Response->send()\n#2 /var/www/[path_to_site_folder]/vendor/yiisoft/yii2/web/ErrorHandler.php(135): app\components\Response->send()\n#3 /var/www/[path_to_site_folder]/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))\n#4 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))\n#5 {main}\nPrevious exception:\nyii\web\HeadersAlreadySentException: Headers already sent. in /var/www/[partial_path_to_site]…\n’, referer: https://[random_url]

Any idea what can this be?

Could be BOM in source files, or extra spaces at the beginning of the file.

This isn’t an ideal solution, but one fix is in php.ini, look for “output_buffering” and set it to “output_buffering=On” and restart your webserver.

thank you @canreo
What would be the disadvantages of doing this?