How to reduce the memory leak in php?

Answer:
If you are running into PHP memory leaks and frequent our of memory errors you can try moving your code into functions. PHP automatically does garbage collection after each function call. Another thing I see a lot of is not closing your database connection strings after using them as this cause build up and cause memory issues as well.
First answer by Maddswilla. Last edit by Maddswilla. Contributor trust: 0 [recommend contributor recommended]. Question popularity: 2 [recommend question].