According to others, the garbage collector will do this work at the end of execution, however, if you have a long work cycle, you may run into problems if / when you work with large volumes of data or huge arrays.
The solution at this stage is to use unset ($ object), which calls the magic __destruct () function, which you can use if you want to do something with the object (for example, save data in a database).
source
share