memory management - In Objective-c autoReleased Objects are released if no pointer points to them anymore? -
just curiosity... if alter pointer point other autoreleased instance, previous autoreleased instance pointer pointing to, autoreleased ? example ...
nsstring pstr* = [nsstring stringwithstring:@"instance one"]; // sth pstr pstr = [nsstring stringwithstring:@"instance two"]; // sth else pstr
are both of instances autoreleased ??
yes. lifecycle of objects doesn't depend on variables point them (unlike environments garbage-collection). that's why it's possible have variable pointing deallocated object or have memory leaks: objects retained forever no references them.
lifecycle depends on how objects created , how use retain
, release
, autorelease
methods.
it's explained in more details in cocoa memory management guide.
Comments
Post a Comment