NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP and memory usage

Marc Antony Vose suzerain at suzerain.com
Thu Oct 14 22:10:23 EDT 2004


Hi there:

This is a very general question, but I don't know where to begin, but 
generally.  I have, over the years built a fairly complex publishing 
system which is installed on several sites.  Recently, I've noticed 
that my mailing list component is choking; PHP bunks out with a 
memory limit error, which is very unfortunate, since there's no way 
of knowing how many messages were sent before this happened.

I need to address this issue, but I wanted to get people's strategic 
opinions about what to cut out in order to reduce memory consumption.

Basically, my central data class extracts names and email addresses 
out of a database, stores that in an array.  We're talking around 
6,000 users here...not a huge number, but sizable.

Then, I loop through the returned users, create a custom message for 
them by replacing codes in a template, and pass it off to a class of 
mine which is just a wrapper for PHPMailer.

That's the basic structure.

So, what should I do?  A few salient points:

: Do objects and arrays eat up a ton of memory?  Should I instead 
select each user separately inside the loop (more database 
connections, but fewer items stored each time)?

: Should I be unsetting variables as soon as I no longer need them? 
Would this make much of a difference?

: Anything else I should look at?  My goal here is to build it so it 
will scale upward; this project will eventually have tens of 
thousands of users...maybe hundreds of thousands.

Thanks much,

-- 
Marc Antony Vose
http://www.suzerain.com/

What can be shown cannot be said.
-- Ludwig Wittgenstein



More information about the talk mailing list