In most cases, autorelease will have zero effect on the overall memory usage of the application. You only need to take care of the author if you accumulate many instances of objects. For instance:
for (int i = 0; i < 1000; ++i) { NSString* s = [NSString stringWithFormat:@"%d", i]; ... }
In this example, at least 1000 different line instances will be accumulated before everything is released, which is undesirable. This is a situation when you will look for alternatives.
If you want to avoid creating a set of string instances, you can use NSMutableString :
NSMutableString* s = [NSMutableString stringWithCapacity:20]; [s appendFormat:@"%d", 123]; ... [s setString:@""]; [s appendFormat:@"%d", 456]; ...
The question arises as to whether this could be faster than just creating and releasing separate instances of strings, but this pattern may better match what you are trying to execute in your code.
source share