The easiest fix without touching code is to give the machine running the
task plenty of RAM and then increase the PHP memory limit in the ini file
(by default php.ini). This is not necessarily ideal.

Something else to consider is if you are extracting a lot of data out of the
database and using doSelect with Propel, doSelect creates an array of
objects, one object per record in the database. A memory efficient way to do
this is to use doSelectRS for Propel 1.2 and under or doSelectStmt for
Propel 1.3.

In addition, make liberal use of the unset() function. Once you have
processed a variable containing a lot of data that you no longer need unset
that variable which removes it from memory immediately and frees it up for
use elsewhere. One example:

$smaller_array = array();
foreach ($really_big_array as $key=>$value)
{
  if ($some_condition == true)
  {
    $smaller_array[$key]=$value;
  }
}
// Get that memory back
unset($really_big_array);

On Wed, Sep 1, 2010 at 11:11 AM, PieR. <[email protected]> wrote:

> Hi,
>
> I have a sfTask in CLI wich use lot of foreach and preg_matches, and
> unfortunatly PHP return an error "Allowed memory size...." in few
> minutes.
>
> I read that PHP clear the memory when a script ends, so I tried to run
> tasks inside the main task, but the problem still remains.
>
> How to manage this memory issue ? clear memory or launch tasks in
> separate processes ?
>
> The final aim is to build a web crawler, wich runs many hours per
> days.
>
> Thanks in advance for help,
>
> Regards,
>
> Pierre
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>



-- 
Gareth McCumskey
http://garethmccumskey.blogspot.com
twitter: @garethmcc

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to