I'm porting a sizable web application to some shared website hosting atmosphere. The application was designed in PHP 4. The brand new atmosphere has PHP 5.2.
For whatever reason, the applying is seeping tremendous levels of memory when running in PHP 5.2. I'm able to literally watch memory usage studying the roof using memory_get_usage(), until it reaches the limit of 64 Megabytes (that is very generous inside a shared atmosphere, the website accustomed to run with 12 or 16 Megabytes on PHP 4).
I suspect that this can be a side-effect of something which has transformed in PHP 5, possibly the handling of object references in arguments. However, the quest for the specific behavior(s) that create(s) the leak is very difficult because the application is extremely complex, and partially not so well crafted (yes, it's mine).
Because the application is a component of a shared webspace, I am unable to make use of the classical debugging facilities (so far as I understand). I'd very, greatly prefer to avoid re-creating the atmosphere in your area, like me focusing on the project literally all day long for a while.
So my questions are:
Does anybody know typical PHP4 => 5 transition issues, especially when confronted with considerable amounts of objects, that could be the reason for my leak(s)
Does anybody know some type of debugger-independent, script-only "graphical scope dump" tool for that variables utilized by PHP that can help me discover which variables are eating up these large numbers of memory?
Thanks ahead of time. Pekka
One common one I discovered in a single discharge of 5.2 was that strtotime leaked without memory_get_usage catching it. Altering to strptime fixed the problem.
There's a bug report with this for five.2.8 - http://bugs.php.internet/bug.php?id=46889.
To resolve this problem I'd:
- Profile the script with xdebug+wincachegrind (as well as other profiler) and/or firephp.
- Switch on the STRICT mode to obtain all of the php error + notices.
Doing that, you'll have the ability to:
- Optimize your code. (Getting rid of the errors/warning/notices can accelerate your code)
- Clean your code. (While using proper php5 object syntax are only able to be great for that performance).
The item model totally transformed from PHP4 to PHP5. Without a doubt, the STRICT mode will explain that you ought to not make use of an explicit "went by reference".
Without debugger you are able to open a script that you simply think use many memory and set memory_get_usage function in critical local people.