Your second code snipppet doesn't release the object you created.
self.rootViewController is a property that retains the object. So you're creating an object using alloc, and then the setter method for self.rootViewController will retain it also. You should release all objects that you allocated. Always
What happens is:
- You create an object of type RootViewController using alloc, so the retain count becomes 1
- The object is assigned to a property which also retains the object. So the retain count becomes 2
When self is deallocated later on, the retained RootViewController object will be released, so its retain count becomes 1 again.
Result: you have a memory leak.