Re: Memory Leak in Model::Save()
On Apr 8, 2011, at 07:18, ProFire wrote:
> Well, whether it's memory leaks or not, I'm experiencing a memory
> exhaustion.
> The code would look like this:
>
> $memorySize = memory_get_usage();// X bytes
> $this->model->save($this->data);
> $memorySize = memory_get_usage();// X + 2000 bytes
> $this->model->create();
> $memorySize = memory_get_usage();// X + 2000 bytes
>
> I ran this test a few times by putting it in a function and looping
> it.
> The results are pretty consistent.
> Each Model::Save() increases memory by about 2000 bytes.
> Even after I call Model::Create(), the memory does not reduce.
>
> Is there a way to clear the memory?
> Does anybody also experience a somewhat similar issue? where by each
> Model::Save results in an increase of memory?
This topic has come up before; read this thread:
http://groups.google.com/group/cake-php/browse_thread/thread/3f4cfb807b5efb08/8878cfa997fb5a98
The guess there is that CakePHP saves the query (and/or information about it) somewhere in memory, possibly for debugging purposes, and that CakePHP simply didn't expect you to be doing so many queries at once that this extra debugging information would exhaust memory. Perhaps you can identify where in the core files this is happening ("look in dbo_source for cacheMethod"), and see if it can be reduced or eliminated.
Alternately, perhaps you can rewrite your process so it doesn't have to do so many queries in one request.
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home