1. PHP Fatal Error ‘yii\base\ErrorException’ with message ‘Allowed memory size of 2147483648 bytes exhausted (tried to allocate 1084897244 bytes)’. See Figure 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. Downloaded file: https://webtv-test.oss-cn-beijing.aliyuncs.com/rmhadmin/vod/2020/12/02/b73b9e8c3796447494a9dbe6dc66e2ad/b73b9e8c3796447494a9dbe6dc66e2ad_h264_1200k_mp4.mp4 . Its size is 1.44 GB. In the local environment, this file was successfully downloaded, with memory usage: 6.376 MB and time consumed: 916,308 ms. See Figure 2.

3. The uploaded file has a size of 50.5 MB. In the local environment, this file was successfully uploaded, with memory usage: 164.813 MB and time consumed: 43,244 ms. The uploaded file has a size of 117 MB. In the local environment, this file was successfully uploaded, with memory usage: 362.813 MB and time consumed: 97,774 ms. It can be concluded that the memory usage is approximately 3 times the file size. See Figure 3 and Figure 4.


4. There is currently no better solution for optimizing memory usage. Therefore, the issue was ultimately resolved by modifying the resource limit configuration option in php.ini. memory_limit = 4096M. This sets the maximum amount of memory a script is allowed to allocate. The uploaded file has a size of 1.01 GB. No further errors occurred.
5. However, when uploading a file with a size of 1.44 GB, the error still occurred. memory_limit = 6144M. No further errors occurred.
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}
