When you create an object, and you assign it to some variable, it’s termination isn’t tied up to the lifetime of a given variable.
This means that with the destruction of the variable, only a reference to the object is destroyed, but the object itself is still allocated in the memory.
If there are too many objects in the memory, the program will eventually run out of resources and won’t be able to perform further operations.
Thanks to the techniques such as Garbage Collection or Automatic Reference Counting, we don’t need to do that anymore.
Here’s how they work.
Please Like and Subscribe for more weekly videos!
Follow me on Twitter: / thecompscirocks
Follow me on Instagram: / thecompscirocks
Follow me on Facebook: / thecompscirocks
Some sources & further reading:
https://en.wikipedia.org/wiki/Object_...
https://en.wikipedia.org/wiki/Referen...)
https://en.wikipedia.org/wiki/Garbage...)
https://en.wikipedia.org/wiki/Automat...
http://www.thomashanning.com/retain-c...
https://en.wikipedia.org/wiki/Memory_...
https://www.dynatrace.com/resources/e...
https://developer.apple.com/library/c...