-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Model Validation Leaks Memory #16566
Comments
I think I reported this Bug on the discord. It's not the validation, it's the model manager, who keeps a copy of every model and this grows unlimited |
@noone-silent is this confirmed or it's just a guess? Do you know if someone is looking into it? I'm having memory leak problems in a forever-running CLI script |
Yes, this is where you can experience it. We had the same problem, our container crashed, because the memory was only growing. I debugged it and found out, that the ModelsManager keeps every Model and the relations in memory. So it is confirmed on our side. We overwrite the models to always use a new ModelsManager public function initialize(): void
{
// Only run this on the first initialization.
// When there are non critical tasks, place it outside of this if.
if ($this->modelsManager instanceof Manager === false) {
$this->useDynamicUpdate(true);
$this->modelsManager = new Manager();
$this->modelsManager->setDI($this->getDI());
}
} Also you need to overwrite the |
@maxgalbu If this fixes your issues too, please post it here. |
@noone-silent actually, it wasn't models that were leaking for me, I did find another memory leak: #16571 |
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
The text was updated successfully, but these errors were encountered: