关于ios内存管理的问题
sdk是ios6.1,不开ARC。
#import <sys/sysctl.h>
#import <mach/mach.h>
-(id)init
{
self=[super init];
[self usedMemory];
[self addtitle:@"d"];
[self usedMemory];
return self;
}
-(void)addtitle:(NSString *)title
{
for (double i=0; i<200000;i++) {
// NSString *T2=[@" > " stringByAppendingString:title];
NSObject * T2=[[NSObject alloc]init];
[T2 release];
}
}
- (void )usedMemory
{
task_basic_info_data_t taskInfo;
mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
kern_return_t kernReturn = task_info(mach_task_self(),
TASK_BASIC_INFO,
(task_info_t)&taskInfo,
&infoCount);
if (kernReturn != KERN_SUCCESS
) {
NSLog(@"Nofound");
}
NSLog(@"Memery%f", taskInfo.resident_size / 1024.0 / 1024.0);;
}