How to debug memory allocation issues?

Posted by amitabh on Stack Overflow See other posts from Stack Overflow or by amitabh
Published on 2010-06-09T15:17:48Z Indexed on 2010/06/09 15:52 UTC
Read the original article Hit count: 234

Hi I am writing an iPhone app that that is trying to create a second a view when the user clicks on an element in UITableView. The code looks like

  ReplyToViewController *reply = [[ReplyToViewController alloc] initWithNibName:@"ReplyTo" bundle:nil];
 reply.delegate = self;
 Message *message = [resultData objectAtIndex:indexPath.row];
 int dbid = [message.bizid intValue];
 NSLog(@"dbid=%d",dbid);

 reply.currentMessage = message;
 reply.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
 [self presentModalViewController:reply animated:YES];

The reply object gets created properly and the view is proper. Last line in above code segment calls some framework code which eventually calls the viewDidLoad method of the ReplyToViewController. Address of the reply object in the above code and the address of the object in viewDidLoad is not same.

Any idea where this new object is coming from? How do I debug? I also added init method the following method in ReplyToViewController hoping that it will get called and I can find who is creating this new object. But it does not stop in this method.

Any help will be greatly appreciated.

- (id) init
{ 
 /* first initialize the base class */
    self = [super init]; 
 return self;
}

// Following gets called from the 1st code segment.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) 
 {
        // Custom initialization
    }

    return self;
}

- (void)viewDidLoad 
{
    [super viewDidLoad];
    NSLog(currentMessage.text]; // THIS returns nil and the program fails later in the code.
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-leaks