I'm using Magento version 2.4.1 hosted on AWS EC2 and using AWS ElastiCache for Redis (5.0.6) to store session
bin/magento --version
Magento CLI 2.4.1
We previously encountered issue with memory limit as below
"Fatal Error: 'Allowed memory size of 792723456 bytes exhausted (tried to allocate 4096 bytes)' in '\/home\/demo.7hit.vn\/release\/1610350759\/7hit\/vendor\/magento\/module-csp\/Model\/BlockCache.php' on line 78"
Per our understanding, the value was limited to 756MB. Then we updated value inside .user.ini, php.ini and now we're facing out of memory issue when checking report/api
"Fatal Error: 'Out of memory (allocated 482934784) (tried to allocate 20480 bytes)' in '\/home\/demo.7hit.vn\/release\/1611044763\/7hit\/vendor\/magento\/framework\/Serialize\/Serializer\/Json.php' on line 37
"Fatal Error: 'Out of memory (allocated 202440704) (tried to allocate 20480 bytes)' in '\/home\/demo.7hit.vn\/release\/1611044763\/7hit\/vendor\/magento\/framework\/Serialize\/Serializer\/Json.php' on line 37
[root@ip-10-0-3-88 current]# php -r "echo ini_get('memory_limit').PHP_EOL;"
-1
[root@ip-10-0-3-88 current]# php -i | grep memory
memory_limit => -1 => -1
Collecting memory statistics => No
output of 2 files [Magento-root-folder]/.user.ini and [Magento-root-folder]/pub/.user.ini
memory_limit = -1
max_execution_time = 18000
session.auto_start = off
suhosin.session.cryptua = off
value inside /etc/php.ini
; Default Value: -1 (Unlimited)
memory_limit = -1
output of free -m
[root@ip-10-0-3-88 pub]# free -m
total used free shared buff/cache available
Mem: 7525 3302 2845 24 1377 3901
My colleague reported that restarting AWS ElastiCache sometimes helps to resolve the issue. I'm not sure if they're relevant to each others. Is there anyone help us to understand the root cause and how to fix it.?
Thanks a lot!
What's your PHP Version?
kindly update if it's not 7.4
Note: if you update PHP then kindly update the vendor dependencies with
composer update
also, try to remove ElastiCache and install Redis locally
kindly Accept as a Solution if this works for you and give Kudos