Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ARC環境で メモリリークを起こす 7つの方法

4,511 views

Published on

ARC環境で メモリリークを起こす 7つの方法

  1. 1. ARC環境でメモリリークを起こす 7つの方法
  2. 2. ①循環参照@interface Hoge : NSObject@property (strong, nonatomic) Hoge *hoge;@end@implementation Hoge@end Hoge *h = [[Hoge alloc] init]; h.hoge = h;
  3. 3. ②MEMCPYHoge *h = [[Hoge alloc] init];memset(&h, 0, sizeof(id));
  4. 4. ③OBJC_MSGSENDHoge *h = [[Hoge alloc] init];objc_msgSend(h, NSSelectorFromString(@"retain"));
  5. 5. ④CFRETAINHoge *h = [[Hoge alloc] init];CFRetain((__bridge CFTypeRef)h);
  6. 6. ⑤__BRIDGE_RETAINEDHoge *h = [[Hoge alloc] init];void *p = (__bridge_retained void *)h;
  7. 7. ⑥CLASS_REPLACEMETHOD Hoge *h = [[Hoge alloc] init]; class_replaceMethod( [Hoge class], NSSelectorFromString(@"release"), imp_implementationWithBlock(^(){}), "");
  8. 8. ⑦MACH_OVERRIDEどうもC言語の関数を書き換えるらしい。面白そうだけど難しそう!誰か教えて!
  9. 9. タブーをあえてやるのも面白い!

×