-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak - binds not being cleared after find() #1604
Comments
I will investigate and return with more details. |
Aha! |
How about an example code? |
Here is an example project. CI4Issue.zip Model class TrashModel extends \CodeIgniter\Model {
public $table = 'trash';
public $id;
public $content;
} Controller public function exampleWithMemoryLeak()
{
$total = 2500; // ~Max for 120MB
$printInterval = 100;
$model = new TrashModel();
for($i = 0 ; $i < $total ; $i++) {
$model->find($i);
if(! ($i % $printInterval)) {
Data::memory("$i items");
Data::debug(serialize($model));
}
}
$this->response->setJSON(Data::getStore());
$this->response->send();
} Data::memory and Data::debug is a debugging tool I use. CREATE TABLE `trash` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; Check the output of Check the output of public function exampleWithoutMemoryLeak()
{
$total = 10000;
$printInterval = 100;
for($i = 0 ; $i < $total ; $i++) {
$model = new TrashModel();
$model->find($i);
if(! ($i % $printInterval))
Data::memory("$i items");
}
$this->response->setJSON(Data::getStore());
$this->response->send();
} |
Just pushed a fix. Let me know if you're running into issues with it. |
Version: Alpha.4.
Memory usage keep increasing when saving a many models. Memory usage raises above 128MB when saving 1.000 models with 10 properties.
I tried setting
$skipValidation = true
and it fixed the issue. Now memory usage is ~2MB. I do not have any validation rules.Looks like a memory leak in the validation part.
Sorry, I do not have further details.
The text was updated successfully, but these errors were encountered: