tags:

views:

181

answers:

3

I am currently working on an export function in cakephp app and im doing a query that is getting around 10,000 rows each export which cake can handle but debug_kit seems to be using lot of memory and putting me over 128mb of memory used.

I have tried tried writing this in the top of the function but debugkit is still getting involved and using large amounts of memory.

Configure::write('debug',0);
A: 

Use

Configure::write('debug',0);

in /app/config/core.php

Or use it in the beforeFilter() callback on the controller. That would stop the debugging for the entire controller if you don't check manually for the current action (in $this->params['action']).

If your model has multiple associations you should take a look at the containable behavior

http://book.cakephp.org/view/51/Controller-Attributes

HyperCas
That will stop it of course but i want to stop on a per action basis as i still would like to use it in other locations.
Shard
you could try the beforeFilter() callback
HyperCas
+3  A: 

HyperCas is correct in suggesting the beforeFilter() callback as an appropriate solution.

The code could look something like this in the controller where the action (ie, export) resides:

function beforeFilter() {
    // filter actions which should not output debug messages
    if(in_array($this->action, array('export'))) {
        Configure::write('debug', 0);
    }
}

You would adjust array('export') to include all the actions you want to prevent debug.

Benjamin Pearson
A: 

you can also switch the debug level in the config.php to 0. this will disable the debug kit automaticaly + your application will use even less memory.

ondrobaco