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

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

3,605

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. タブーをあえてやるのも面白い!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×