Just curious why is it sometimes necessary to make a code sleep() specially if
the code is long running script? I know its a dumb q but your knowledge would help
Thanks
why do I need to make my Script sleep?
Moderator: General Moderators
what i was actually wondering is how to make memory more efficient while running a script. Lets say i am sending an eblast with 100000 emails
if i query those emails using mysql_fetch_array, those emails will be stored in memory. what i wanted to do is dump the emails that has already run thrugh the script. So let say ive sent the first 100 emails of the 100000 i want to dump those 100 in the array memory because its useless. Mistakenly I was thinking that the sleep commands "refreshes" the memory of the script. please correct me.
if i query those emails using mysql_fetch_array, those emails will be stored in memory. what i wanted to do is dump the emails that has already run thrugh the script. So let say ive sent the first 100 emails of the 100000 i want to dump those 100 in the array memory because its useless. Mistakenly I was thinking that the sleep commands "refreshes" the memory of the script. please correct me.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
sleep() does little as far as memory is concerned. It is used to prevent your script from inhaling the server's processor(s), nothing more.
If these emails are sent per record you aren't sucking up major amounts of memory as far as PHP is concerned provided you don't have PHP store more than a record. Generally there's little reason to store more than the current record if you're sending customized emails.
If these emails are sent per record you aren't sucking up major amounts of memory as far as PHP is concerned provided you don't have PHP store more than a record. Generally there's little reason to store more than the current record if you're sending customized emails.
Which means that you should use an unbuffered query, like mysql_unbuffered_query() or PDOfeyd wrote:If these emails are sent per record you aren't sucking up major amounts of memory as far as PHP is concerned provided you don't have PHP store more than a record.
You might want to consider something like majordomo instead of a selfmade php script for your non-spam opt in/out mailing list
sleep() is important in infinite loops to delay the script and prevent it from using up all available memory.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.