我有这个循环的内存问题。我使用 ARC,所以通常我不能释放任何对象。但是在这个循环过程中,内存会增加,iPad会在片刻后崩溃(没有警告和错误)。
有没有办法解决这个问题?我不明白为什么记忆会长大?
谢谢您的帮助。
_rawdatalocal = [NSEntityDescription insertNewObjectForEntityForName:@"RAWDATA"
inManagedObjectContext:managedObjectContext];
for(int j = 1; j <[array count];j++)
{
NSArray *values = [[NSArray alloc] initWithArray:[[array objectAtIndex:j] componentsSeparatedByString:@";"]];
if([values count] == 12)
{
_rawdatalocal.accX = [[NSNumber alloc] initWithInt:[[values objectAtIndex:1] intValue]];
_rawdatalocal.accY = [[NSNumber alloc] initWithInt:[[values objectAtIndex:2] intValue]];
_rawdatalocal.accZ = [[NSNumber alloc] initWithInt:[[values objectAtIndex:3] intValue]];
_rawdatalocal.gyrX = [[NSNumber alloc] initWithInt:[[values objectAtIndex:4] intValue]];
_rawdatalocal.gyrY = [[NSNumber alloc] initWithInt:[[values objectAtIndex:5] intValue]];
_rawdatalocal.gyrZ = [[NSNumber alloc] initWithInt:[[values objectAtIndex:6] intValue]];
_rawdatalocal.magX = [[NSNumber alloc] initWithInt:[[values objectAtIndex:7] intValue]];
_rawdatalocal.magY = [[NSNumber alloc] initWithInt:[[values objectAtIndex:8] intValue]];
_rawdatalocal.magZ = [[NSNumber alloc] initWithInt:[[values objectAtIndex:9] intValue]];
_rawdatalocal.temperature = [[NSNumber alloc] initWithFloat:[[values objectAtIndex:10] floatValue]];
_rawdatalocal.temps = [[NSNumber alloc] initWithInt:[[values objectAtIndex:11] intValue]];
}
PS:通常下面的行在循环中
_rawdatalocal = [NSEntityDescription insertNewObjectForEntityForName:@"RAWDATA"
inManagedObjectContext:managedObjectContext];