Reputation: 6012
I'm working on a Cocoa App. Most of the app is ARC, but I'm using a version of the Amazon SDK for iOS which is MRC. (I've made only a few updates to the amazon classes so it works with Cocoa).
I've disabled ARC for all of amazon's files I'm using with -fno-objc-arc.
If I use one of the MRC classes from Amazon SDK in one of my ARC classes. Do I need to surround it with an @autorelease?
I'm experiencing memory leaks from Amazon classes and have not been able to get to the source of it.
For example. Let's say the MRC class is this: (this is very contrived to simplify what I'm asking):
@implementation MyMRCClass
- (void) doStuff {
NSArray * tmp = [[[NSMutableArray alloc] init] autorelease];
}
@end
Then let's say I use that class somewhere in ARC:
@implementation MyARCClass
- (void) doSomethingWithMyClass {
[self.myClass doStuff];
}
@end
Do I need to wrap calls to MyMRCClass with @autorelease?
@implementation MyARCClass
- (void) doSomethingWithMyClass {
@autorelease {
[self.myClass doStuff];
}
}
@end
Thanks.
Upvotes: 0
Views: 192
Reputation: 46598
You don't need @autorelease
unless it is the entry point of a new thread. The autorelease pool on main thread should be created for you in your main function.
As long as you have balanced retain
/release
and correct naming conversion, and no retain cycle, it should be fine.
MRC doesn't change anything if you do it correctly, it should behave just like ARC.
Read documentation for when to use it.
Upvotes: 1