Please tell me how in Yii 2 to remove the model instance after all operations with it?

Let's say I declare a model instance:
$customer = new Customer();

And get from the user some data that I need to save:
$customer->last_name = $post['last_name'];
$customer->fist_name = $post['first_name'];
$customer->patronymic = $post['patronymic'];
$customer->birth_date = $post['birth_date'];
if (!$customer->save()) {
 echo "Error adding customer ";
} else {
 echo "Customer added successfully";

Here after using this instance how to remove it from memory?
unset($customer); //not helping
Some of the functions gets an error that not enough memory to the script, even if you set 3GB using ini_set('memory_limit', '3076M')
March 12th 20 at 08:08
1 answer
March 12th 20 at 08:10
If 3GB is not enough it is definitely not the case for the model, probably infinite loop somewhere.
In General it is always possible to overwrite the variable:
$customer = null;
Why did You decide that it's her?
Empirically, it was verified that the RAM is not cleared after you run the script, in which the cycle records are created in the database using ActiveRecord. Like the framework remembers all previous values of the variable $customer.
Endless cycle there is no sure.
How to detect memory leaks in the project? Arrange each function memory_get_usage() ?
Have You had any similar problems? That runs a simple script like, but it eats a lot of memory, infinite loops there, everywhere apart from the echo to see where the code we are now.
As programmers all over the world and, in particular, Russia does solve the memory leak problem in high-load projects?
I would be very grateful, if advise something! :) - emmy.McDermott76 commented on March 12th 20 at 08:13
in which the cycle records are created in the database

code in Studio - emie66 commented on March 12th 20 at 08:16

Find more questions by tags Yii