Re: free allocated memory: HOW ?
| From: | Arthur Erdös | Date: | Thu, 12 Apr 2007 15:59:41 +0000 |
| Subject: | Re: free allocated memory: HOW ? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252751@lists.php.net to get a copy of this message | ||
> 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)
the read method does following:
// read the newsletter template
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
fclose($fh);
return $theData;
> >
> > 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)