Describe the bug
On a new phalcon project Trying to create models in a loop and the model has a validation function will leak memory
To Reproduce
I set up a user model and then added this like in the example
public function validation()
{
$validator = new Validation();
$validator->add(
'email',
new Uniqueness(
[
'message' => 'The customer email must be unique',
]
)
);
return $this->validate($validator);
}
Created a loop like this
$count = 100;
for ($i = 0; $i <= $count; $i++) {
$before = microtime(true);
$user = new Users([
'firstname' => 'John',
'lastname' => 'Doe',
'password' => 'securepassword',
'is_active' => true,
]);
$user->create();
$after = microtime(true);
echo sprintf(
'Took %s seconds. Used %s memory',
round($after - $before, 4),
round(((memory_get_usage() / 1024) / 1024), 4) . 'M'
) . PHP_EOL;
}
Over each model it's still holding a refereance to something
Took 0.0199 seconds. Used 1.6799M memory
Took 0.0182 seconds. Used 1.6803M memory
Took 0.0185 seconds. Used 1.6806M memory
Took 0.0182 seconds. Used 1.681M memory
...
Took 0.0179 seconds. Used 1.7147M memory
Took 0.0181 seconds. Used 1.715M memory
Took 0.0181 seconds. Used 1.7154M memory
Took 0.0185 seconds. Used 1.7158M memory
Took 0.0181 seconds. Used 1.7161M memory
Took 0.0187 seconds. Used 1.7165M memory
Expected behavior
I'm pretty sure this should get GC'd I checked with gc_status() and it looks like the PHP garbage collector is running but it's not freeing this memory
Details
- Phalcon version: 5.6.1
- PHP Version: 8.2.16
- Operating System: Ubuntu
- Installation type: Downloaded via git releases
- Server: Apache
- Other related info (Database, table schema): MariaDB
Describe the bug
On a new phalcon project Trying to create models in a loop and the model has a validation function will leak memory
To Reproduce
I set up a user model and then added this like in the example
Created a loop like this
Over each model it's still holding a refereance to something
Expected behavior
I'm pretty sure this should get GC'd I checked with gc_status() and it looks like the PHP garbage collector is running but it's not freeing this memory
Details