Last active
December 22, 2015 03:48
-
-
Save amay077/6412557 to your computer and use it in GitHub Desktop.
ARC のメモリ解放タイミングを調べた ref: http://qiita.com/amay077/items/95a4139e6f553d8a56a1
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
- (IBAction)buttonDownWithArc:(id)sender { | |
NSString* path = @".../bigdata.img"; | |
for (int i = 0; i < 10000; i++) { | |
NSData* data = [NSData dataWithContentsOfFile:path]; | |
[NSThread sleepForTimeInterval:0.5]; | |
data = nil; | |
} | |
} |
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
- (IBAction)buttonDownNoArc:(id)sender { | |
NSString* path = @".../bigdata.img"; | |
for (int i = 0; i < 10000; i++) { | |
NSData* data = [NSData dataWithContentsOfFile:path]; | |
[NSThread sleepForTimeInterval:0.5]; | |
[data dealloc]; | |
data = nil; | |
} | |
} |
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
- (IBAction)buttonDownWithArcAndAutoRelease:(id)sender { | |
for (int i = 0; i < 100; i++) { | |
@autoreleasepool { | |
NSData* data = [NSData dataWithContentsOfFile:_path]; | |
[NSThread sleepForTimeInterval:0.5]; | |
} | |
} | |
} |
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
for (int i = 0; i < 画像数; i++) { | |
/* | |
* 画像読み込み処理 | |
* autoreleaseされたオブジェクトが大量発生。 | |
* NSAutoReleasePoolのオブジェクトが破棄されないため | |
* いずれメモリ不足発生! | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment