This is my code in ViewController.m file,
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"%f",[self usedMemory]);
NSMutableArray *array= [[NSMutableArray alloc]init];
for (int i = 0; i < 100; i++) {
NSMutableData *data = [NSMutableData dataWithLength:10000];
[array addObject:data];
}
NSLog(@"%f",[self usedMemory]);
for (int i = 0; i < 100; i++) {
[array removeObjectAtIndex:0];
}
NSLog(@"%f",[self usedMemory]);
}
Here is the conslut result:
2015-01-26 22:39:00.058 audio_memory_test[9050:874963] 25.011719
2015-01-26 22:39:00.060 audio_memory_test[9050:874963] 26.312500
2015-01-26 22:39:00.060 audio_memory_test[9050:874963] 26.312500
My question is : Why delete objects in the array, the memory has not been released ? and what removeObjectAtIndexmethod has done? How to do can release memory?
Aucun commentaire:
Enregistrer un commentaire