Skip to content

Instantly share code, notes, and snippets.

@theicfire
Last active July 10, 2020 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theicfire/c86f1e7f9687a5e8f1a974cdd7b0cb9f to your computer and use it in GitHub Desktop.
Save theicfire/c86f1e7f9687a5e8f1a974cdd7b0cb9f to your computer and use it in GitHub Desktop.
/**
* Usage: Call BigAutorelease* a = create_autorelease_object();. If the dealloc message is not printed, this code is not running in an autorelease pool block.
*/
@interface BigAutorelease: NSObject
@property(strong, nonatomic) NSMutableArray *arr;
@end
@implementation BigAutorelease
- (instancetype)init {
NSLog(@"Make BigAutorelease");
self = [super init];
_arr = [NSMutableArray arrayWithObjects:@1, @2, @3, nil];
for (int i = 0; i < 100000; i++) {
[_arr addObject:@4];
}
return self;
}
- (void)dealloc {
NSLog(@"Dealloc sampleClass");
}
@end
BigAutorelease *create_autorelease_object() {
__autoreleasing BigAutorelease *ret = [[BigAutorelease alloc] init];
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment