Re: free allocated memory: HOW ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Arthur Erdös wrote:
>> int memory_get_usage ( [bool $real_usage] )
>>
>> Returns the amount of memory, in bytes, that's currently being allocated to your PHP script.
>>
>> it returns the number of *bytes* !!!
> 
> sure, and memory_get_usage()/1048576 returns the number of megs, or am i
> wrong? o_O
> 
>>>> exactly how much ram does the server in question have that you can
>>>> allow a single script to schlock up almost 2gigs ??
>>> dev machine 4 GB, webserver 8 GB of RAM
>> does running top in the cmdline confirm that the script is really eating 100's of Megs?
>>
> 
> OMFG, YES it does... top shows the script eating 658 megs right after
> reading the template (~125 megs before)

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.

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);

> 
>>> 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.

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux