How to solve the problem that the php script takes up too much memory and cannot be released or there is insufficient memory

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.

4. Other solutions (source Chat)

Guess you like

Origin blog.csdn.net/mo3408/article/details/132952642