When developing games, it is vital that we are wise at resource management and reuse the resources available to us. We should not waste resources since devices do not have an infinite amount of resources available.
Thus, by wasting resources, we are increasing the overhead on the device's memory and processor, impacting performance. For instance, if we keep creating many new objects in a scene, there is a huge amount of information to store, calculate, and handle. This will slow down the game and could potentially crash the game due to it running out of memory or an overload of calculations.
It is therefore best practice to reuse or destroy (remove) objects once they are no longer needed, particularly when they are no longer on screen.
Garbage collection is a type of memory management whereby the garbage collector tries to reclaim memory that is no longer being used by the game. Unity performs garbage collection automatically; however, based on the game's design, we need...