I'm using Codeigniter framework (development version from github) for one of my projects. Project itself is not big just a few controllers and models and I have a memory leak. In 12 hours my rams constantly go up and i have to restart php5-fpm to clean them. Where should I start looking for memory leak? I mean is it loops or variables and what tools can I use for this to investigate?
To find a memory leak, look at how much RAM the system is using. The Resource Monitor in Windows can be used to accomplish this. In Windows 8.1 and Windows 10: To open the Run dialogue, press Windows+R, then type "resmon" and click OK.
What is a memory leak in PHP? A memory leak in PHP is a condition that causes sections of code to continue using memory even though that memory is no longer needed.
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it reduces the performance of the computer by reducing the amount of available memory.
A very old question, but for those facing this problem (since it is still a problem for some of us using CodeIgniter)... per the developer: By default, CodeIgniter keeps an array containing your history of queries.
Look into setting save_queries
to false
in your database configuration.
I had the same problem with a work project and this dramatically reduced our memory usage.
If you need to find the exact cause of your memory leak, I will suggest you to use a memory profiler like XHProf.
This is the best way to debug the php scripts and what is the cause of memory leak.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With