Monday, July 4, 2011

cacheQueries and memory usage

This is driving me crazy. Hopefully someone can help. I'm parsing a
large file and saving that data to a database. My script is quickly
consuming all available memory. I upped the PHP memory limit to 1GB
but this is a hack. I've narrowed the problem down to the model's
cacheQueries setting. It appears to have no effect whatsoever. If I
however use the query() method directly of a model, the memory usage
remains low and constant.

Here's part of my code that being run in a loop as part of a shell
(console):

The "MasterIssue" class has no related models.

$this->MasterIssue->cacheQueries = false;

// This causes memory issues!!!
$issues = $this->MasterIssue->find('all', array(
'conditions' => array('MasterIssue.cusip LIKE' => $cusip_prefix .
'%'),
'fields' => array('MasterIssue.id', 'MasterIssue.cusip')
));

// This does NOT cause memory issues
//$issues = $this->MasterIssue->query("SELECT * FROM master_issues
WHERE cusip LIKE '$cusip_prefix%'", false);

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: