Keith Devens .com |
Wednesday, March 17, 2010 | ![]() |
| I meant what I said, and I said what I meant. An elephant's faithful, one hundred percent! – Horton (Horton Hears a Who, Dr. Seuss) | ||
|
| ← Amazon.com: Books: The Messiah: An Oratorio Complete Vocal Score (G. Schirmer's Editions of Oratorios and Cantatas) | The NY Times bogus weapons-cache story → |

cal wrote:
Keith (http://keithdevens.com/) wrote:
Ha, it's all good. I should have put a smiley face next to that "hey" to make it clear I wasn't actually offended.
calin (http://www.php9.com) wrote:
read more about this myth "PHP isn’t so great at being a daemon... Leaks memory like a sieve":
http://www.php9.com/index.php/archives/2004/10/28/php-leaks-memory-myths/
Gaetano Giunta wrote:
I'll be darned! I've had lottsa PHP scripts running as daemons for years, and nobody ever told me that. Guess I'll have to shut them off now!!!
Facts:
- PHP engine does NOT leak memory on its own
- programmers are much more likely to have leaks in their own code
a very simple example: an array that is added a value every loop iteration, say $a[] = newelement();, and is never reset.
Just as with any other daemon, be careful in what you code. Close and reopen database connections whenever a SQL error is triggered (nr.1 tip), free resources as soon as you can and so on...
Keith (http://keithdevens.com/) wrote:
Well, it's good to hear some counterexamples about running PHP as a daemon. I haven't done it myself, so I don't have direct experience with it. I have to assume Cal did tests with it before he coded his daemon in Java and that he's speaking from experience.
Ah, here's a comment he left on the above post at php9.com:
that comment, “like a sieve", is from a presentation i made about how we were using php for an app which is currently doing the rounds.
our experiments with php showed that it wasn’t freeing memory correctly when large variables went out of scope. the tests were basically loading big files into memory, processing them with objects and then freeing all the data - the longer the process ran, the more memory it consumed. it’s possible that it’s been fixed since, but at the time this was one of the reasons why we didn’t write any daemons in php.
Another commenter on the page claims that even PHP 5 still "leaks quite a bit". So, it seems it's still something to be wary of, at least. I'll keep in mind your tip about closing and reopening db connections upon errors, thanks.
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.128s.
(Used 8 db queries)
that should have read: