HI, I am working on optimizing my iphone project for proper memory management. my question is:
what's the difference between releasing an object inside dealloc or releasing in the same method where we init it?
Thanks!
HI, I am working on optimizing my iphone project for proper memory management. my question is:
what's the difference between releasing an object inside dealloc or releasing in the same method where we init it?
Thanks!
Generally, you want to release an object as close to the point in the code where you initialize it as possible. If you have local variables in a method that you are init
-ing, you release them before the method returns.
This, however, is not possible with instance variables, since they stick around with the objects; thus, you release them in a dealloc
method.