Last active
July 10, 2020 18:53
-
-
Save chaselambda/c86f1e7f9687a5e8f1a974cdd7b0cb9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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