Re: free allocated memory: HOW ?

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

 



Couple of questions come to mind...

1. How big is this template that you're loading? Not sure why almost any HTML file would take up 300+ meg of memory when loaded into a variable.  Are you loading images and other content in as well or just the HTML file?

2. Replacing the placeholders with actual data increases memory that much?  Damn.. maybe I'm just ignorant of how PHP maintains things in memory, but that seems kind of nuts too

3. Do you have to store each newsletter in memory at each loop or can you send them out then move to the next one without storing them in an array or whatever you're doing?

4. Please tell us these 'newsletters' don't contain information on "male enhancement products" or "govt seized puppies"..hah

-TG

= = = Original message = = =

I am using PHP version 5.1.2. on my dev machine. The same problem with
PHP 5.2.1 on webserver.

I am generating mails based on a HTML Template. After reading the 
template with fread() memory_get_usage() says ~386 MB in use...

Then the placeholders in the read template are replaced by customized
values within a loop. The size of the used memory grows permanently in
each loop by approx 30 MB (100 newsletters are generated per loop).

any ideas what i am doing wrong and where i [ab]use php? ^^


Jochem Maas schrieb:
> Arthur Erd~s wrote:
>> Hello all,
>>
>> is there a way to free memory allocated by variables in PHP?? This is a
>> very important issue concerning long running scripts...
> 
> this is a recurrent problem - not much can be done about it AFAIK ... I'd
> be very glad to be proved wrong.
> 
>> I have a script that generates > 5000 Newsletters and when the script
>> finishes it uses 1.8 GB (!!) of RAM. Although I am using unset() to
>> clean up variables (tried with $var = null too).
> 
> okay this does suggest your doing something else very wrong - I personally
> have code that regularly generates upto 20,000 individualised newsletters without
> going anywhere near this ammount of memory - granted I've hit my memory limit
> a couple of times and had to jack it up to 128Megs (in practice the script grab just over
> 64Megs when it's doing it's worst).
> 
> what version of php are you [ab]using?
> 
>> I've read sth about php not giving the allocated memory back to the OS
>> until a script finishes, is that right?? Is it possible to free the
>> memory "by hand"?
>>
>> Any suggestion is appreciated!
>>
>> thx in advance
>>

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


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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