Memory Management iOS dev app doesn't work after a few detail items
Posted
by
user1434846
on Stack Overflow
See other posts from Stack Overflow
or by user1434846
Published on 2012-06-04T10:04:33Z
Indexed on
2012/06/04
10:40 UTC
Read the original article
Hit count: 202
I am working on a project with a tableView controller and the detail views contains CMMotionManager.When i open 5 or 6 detailViews all goes well,but after a while the app goes slow and finally crashes.On instruments the only leak is on main.m , also i must say that I'm using ARC and i can't dealloc or realese the instances.
Here is the code: First the table view:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"Movement";//Master View Controller title bar
UIImage *image = [UIImage imageNamed:@"jg_navibar.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
//Init the array with data
bodypartsMutableArray = [NSMutableArray arrayWithCapacity:26];
BodypartData *part1 = [[BodypartData alloc] init];
part1.bodypartname = @"Shoulder";
part1.movementname = @"Flexion";
part1.fullimageStartingPosition=[UIImage imageNamed:@"2_shoulder_flexion_end_position.jpg"];
part1.fullimageEndedPosition=[UIImage imageNamed:@"2_shoulder_flexion_end_position.jpg"];
part1.thumbimage=[UIImage imageNamed:@"1_shoulder_flexion_landmarks_thumb.jpg"];
[bodypartsMutableArray addObject:part1];
.........
}
then the cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"MyBasicCell"];
BodypartData *part = [self.bodypartsMutableArray objectAtIndex:indexPath.row];
cell.textLabel.text =[NSString stringWithFormat:part.movementname];
cell.detailTextLabel.text =[NSString stringWithFormat:part.bodypartname];
cell.imageView.image =part.thumbimage;
return cell;
}
and the the detailViewdid load:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Init motionManager object and set the Update Interval
_motionManager = [[CMMotionManager alloc]init];
_motionManager.deviceMotionUpdateInterval=1/60; //60 Hz
[_motionManager startGyroUpdates];
if (_motionManager.gyroAvailable) {
_motionManager.gyroUpdateInterval = 1.0/60.0;
[_motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler: ^(CMDeviceMotion *motion, NSError *error)
{
CMAttitude *attitude = motion.attitude;
//Calculation with rotationMatrix
m11 = [NSString stringWithFormat:@"%.02f", attitude.rotationMatrix.m11];
m12 = [NSString stringWithFormat:@"%.02f", attitude.rotationMatrix.m12];
m13 = [NSString stringWithFormat:@"%.02f", attitude.rotationMatrix.m13];
.........
}
© Stack Overflow or respective owner