Well I use more tricks but I think the most important is that when I 
have a controller with many models I don't just pass them in the $uses 
var. I do this because the controller would load all models, and it's 
allmost sure you won't need all of them in all the actions. Instead i 
have a function in app_controller called getMyModel( $modelName ). This 
first checks to see if the model is not loaded, and if is not it calls 
App::import('Model',$modelName), then it instantiates the model, then it 
returns a refference to the model. So instead of 
$this->ModelName->find(..), i to $this->getMyModel->find(..). This way, 
if i only use a few models in an actions, only those will load.(this 
tries to be a rudimentary lazy loading of models).
Another trick is that i define only as few associations as possible (the 
critical ones). Instead I define them in another variable of the model 
(something like $__hasMany = array( 'myassoc' => ....), and i have a 
function in app_model that lets me do quick binds at run time, like: 
$model->doMyBind( 'myassoc' ); I could do the same thing by describing 
the association with $model->bindModel but this is faster, and i don't 
have to define the asociation more than one time. Plus, if i think that 
i'll use that association a lot in a certain context, i user the 
"permanent" option of bindModel.
I have more of these "tricks", and I'm not sure using them is such a 
good practice. I never investigated if they don't provoke other effects 
that would do more bad than good. However, they seem to work so far, and 
I'm happy with them.

ooo.inbox wrote:
> Hello Christian...
> So interesting...
> Btw, i got the memory problem too using CakePHP.
>
> How do you manage it under 8M?
> What things that you do...?
>
> I hope you would to explain me.. thanks ;)
>
> On Feb 19, 4:31 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>   
>> I've noticed that sometimes the out of memory is generated by some
>> infinite recursion loops you create by mistake. It's quite easy to do
>> so.
>> And about the increasing of the php script memory, i tried to avoid it
>> by carefully coding and trying as much to lazy load the models,
>> components and other stuff that I need. So far i managed to keep it
>> under 8M even in large projects.
>>
>> On Feb 19, 2:56 am, "sixs" <[EMAIL PROTECTED]> wrote:> HI,
>>     
>>> I copied the index view and the index in controllers. I have a master and a 
>>> detail and I deleted some fields in the master. It displayed ok an this 
>>> error occurred when I clicked the list of the details.
>>> =================================================================
>>> Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to 
>>> allocate 276481 bytes) in C:\VertrigoServ\www\usa\views\layouts\default.ctp 
>>> on line 55
>>> ===================================================================
>>> Thanks for any help
>>> Jim
>>>       
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to