As another answer rightly points out, this shared singleton will never be released. There are two parts to the answer "why", both of which are taken from the following line:
static MySingleton * sharedObject = nil;
The first is static . static , when used inside such a function, changes the lifetime of a variable, changing it from automatic , the implicit default value, to static . This means that this variable exists for the entire lifetime of the program.
Secondly, this declaration makes sharedObject a strong link. Variables in Objective-C are strong by default, but for pedantry you could write:
static __strong MySingleton * sharedObject = nil;
So: we have a variable that lives throughout your program ( static ), and which maintains a strong reference to the object that it represents ( __strong ). Using these two pieces of information, as well as the fact that you never change the object that the variable points to, you can conclude that sharedObject will never be freed.
source share