Re: free allocated memory: HOW ?
| From: | Jochem Maas | Date: | Thu, 12 Apr 2007 20:09:40 +0000 |
| Subject: | Re: free allocated memory: HOW ? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252782@lists.php.net to get a copy of this message | ||
Arthur Erdös wrote:
>> 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
ah I see.
(guessing from my name you can probably assume I'm not native either)
(I'm not a speaker either - I'm missing a magnet and a cone. ;-)
...
>>> // 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 :(
this is just not right - I can't believe the problem is not in your code somehow.
time to do some simple tests:
to start with write a test script that *only* reads in the relevant file and
see what happens (checking memory usage before and after you read it in).
...
>
> no email goes out, the mails are stored in the database.
yes so you said, but your script should be capable of generating them so fast that
if you *were* to send them out straight away the mail server would get *really* annoyed ..
at one every 3-4 seconds the mail server would laugh at you. if you catch my drift.
>