1. You can solve this problem by setting memory_limit in php
Add to the public header:
// 设置内存限制为 256MB
ini_set('memory_limit', '256M');
2. View Mysql slow log
If the Mysql query is slow, resources will be exhausted during multiple queries.
3. Check whether the PHP code has a large number of loops
Using a large number of loops or recursive calls may result in increased memory usage. Each loop iteration or recursive call creates new variables and data structures in memory.