When I use The Class of NSMutableArray , first I alloc a NSMutableArray,Then Add Five Object to the NSMutableArray, last Remove All Object from the Array .the Memory Used can't Release.
When I use The Class of NSMutableArray , first I alloc a NSMutableArray,Then Add Five Object to the NSMutableArray, last Remove All Object from the Array .the Memory Used can't Release.
The Follow is My Code for the Question:
NSMutableArray * _test = [[NSMutableArray alloc] init] ;
NSString * str = [[NSString alloc]initWithFormat:@"Test12312313"];
NSLog(@"retainCount0:%d",[str retainCount]);
[_test addObject:str];
[str release];
NSLog(@"retainCount0:%d",[str retainCount]);
double duse = [self usedMemory];
NSLog(@"Test0:%.10f",duse);
int n = 0;
{
while (n < 10000 ) {
n++;
NSString * str = [[NSString alloc]initWithFormat:@"Test12312313"];
[_test addObject:str];
str = nil;
duse = [self usedMemory];
NSLog(@"Test1:%.10f",duse);
}
[_test removeAllObjects];
_test = nil;
str = nil;
duse = [self usedMemory];
NSLog(@"Test2:%.10f",duse);
}
duse = [self usedMemory];
NSLog(@"Test3:%.10f",duse);