When an object is no longer needed it can often be safely destroyed to free up memory in the running script.
Instantiating an object may look like this:
$some_object = new some_object();
This object might take up memory for the duration that the script is running. PHP will automatically free up the memory when the script finishes running.
To free up memory instantly, we can use unset() on the variable holding the object:
This should, however, only be necessary when working with memory-heavy scripts; in addition, we might also benefit from unset in environments with a sufficiently high number of concurrently executing PHP scripts.