Re: free allocated memory: HOW ?
| From: | Arthur Erdös | Date: | Thu, 12 Apr 2007 16:34:55 +0000 |
| Subject: | Re: free allocated memory: HOW ? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252765@lists.php.net to get a copy of this message | ||
> don't OMFG me - I can't read your cmdline from here you know,
> and I'm not the one with a completely borked script/system/whatever.
>
a big sorry again for the missunderstanding!! ;) I did not omfg YOU! I
did omfg ME when I saw that the script eats much more memory as
memory_get_usage() returned!! so please excuse me if my wording was
wrong, i'm not a native english speaker oO
Far from it! I am greatly thankfull for people like you and the
community here!
> php will not turn a 20.7Kb file into 400+ Megs of consumed memory - unless your read
> and store it in memory 20000 odd times.
>
> which still leaves the question as to what is taking 125 Megs of RAM *before* you
> even start processing.
>
> >
> > the read method does following:
> >
> > // read the newsletter template
> > $fh = fopen($file, 'r');
> > $theData = fread($fh, filesize($file));
> > fclose($fh);
> > return $theData;
>
> which can more succinctly be written as:
>
> return file_get_contents($file);
>
I'll try to change fread to file_get_contents()...
anyhow, each generation of 100 mails eats approx 30 more megs :(
> >
> >>> the size of the template is 20.7 Kb
> >> no way in hell that 20.7Kb turns into 270 Megs if you read the file into php.
> >>
> >> are you experiencing severe load on the server whilst the script is running?
> >> and/or is the script actually very, very slow?
> >
> > well, the script is not very, very slow... it takes ~3-4 seconds to
> > generate each newsletter (including database querys for the customized
> > data)
>
> 3-4 seconds is dead slow if you ask me - a script like this should be capable of
> making the average mailserver go completely apeshit assuming you'd be mailing the
> newsletters out directly after creating them [rather than storing them in a db] (i.e.
> pumping out lots of emails a second] ... I know this because I have a qmail server
> that has trouble keeping up with my massmailer scripts.
>
no email goes out, the mails are stored in the database.