1、PHP Fatal Error ‘yii/base/ErrorException’ with message ‘Allowed memory size of 2147483648 bytes exhausted (tried to allocate 1084897244 bytes)’。如图1
The command "'/usr/local/php/bin/php' '/mcloud/www/channel-pub-api/yii' 'upload-asset-queue/exec' '45' '7200' '1' '1010' '--verbose=1' '--color=0'" failed. Exit Code: 255(Unknown error) Working directory: / Output: ================ 2020-12-04 14:31:27 [45] common/jobs/UploadAssetJob (attempt: 1, pid: 1010) - Started Error Output: ================ PHP Fatal Error 'yii/base/ErrorException' with message 'Allowed memory size of 2147483648 bytes exhausted (tried to allocate 1084897244 bytes)' in /mcloud/www/channel-pub-api/vendor/yiisoft/yii2-httpclient/src/Request.php:381 Stack trace: #0 [internal function]: yii/base/ErrorHandler->handleFatalError() #1 {main}
2、下载的文件:https://webtv-test.oss-cn-beijing.aliyuncs.com/rmhadmin/vod/2020/12/02/b73b9e8c3796447494a9dbe6dc66e2ad/b73b9e8c3796447494a9dbe6dc66e2ad_h264_1200k_mp4.mp4 。其大小为 1.44 GB。在本地环境中,成功下载此文件,内存占用:6.376 MB,耗费时间:916,308 ms。如图2
3、上传的文件,其大小为 50.5 MB。在本地环境中,成功上传此文件,内存占用:164.813 MB,耗费时间:43,244 ms。上传的文件,其大小为 117 MB。在本地环境中,成功上传此文件,内存占用:362.813 MB,耗费时间:97,774 ms。可以得出结论:内存占用大约为文件大小的 3倍。如图3、图4
4、内存的占用优化,暂无更优的方案。因此,最后通过修改 php.ini 的资源限制的配置选项。memory_limit = 4096M。设置了一个脚本允许分配的最大内存量。上传的文件,其大小为 1.01 GB。未再报错。
5、但是当其上传的文件大小为 1.44 GB 时,仍然报错。memory_limit = 6144M。未再报错。
The command "'/usr/local/php/bin/php' '/mcloud/www/channel-pub-api/yii' 'upload-asset-queue/exec' '68' '7200' '1' '1012' '--verbose=1' '--color=0'" failed. Exit Code: 255(Unknown error) Working directory: / Output: ================ 2020-12-07 17:54:21 [68] common/jobs/UploadAssetJob (attempt: 1, pid: 1012) - Started Error Output: ================ PHP Fatal Error 'yii/base/ErrorException' with message 'Allowed memory size of 4294967296 bytes exhausted (tried to allocate 1551797080 bytes)' in /mcloud/www/channel-pub-api/vendor/yiisoft/yii2-httpclient/src/Request.php:391 Stack trace: #0 [internal function]: yii/base/ErrorHandler->handleFatalError() #1 {main}
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/181599.html