1

In Instrument-Leaks, the following code increasing Allocation memory always, when ever i am pushing PhotosObj .Releasing PhotosObj is not working.

if (PhotosObj) {
    [PhotosObj release];
    PhotosObj=nil;
    PhotosObj=[[Photos alloc]initWithNibName:@"Photos" bundle:nil]; 
}
else {
    PhotosObj=[[Photos alloc]initWithNibName:@"Photos" bundle:nil];
}
[self.navigationController pushViewController:PhotosObj animated:YES]; 

Please clarify me.

Thanks in Advance

boopathi
  • 137
  • 2
  • 9

1 Answers1

0

What kind of variable is PhotosObj? Local, global, or instance variable? I recommend to make it a local variable (and variable name should start with a small letter) like this:

Photos *photosObj = [[Photos alloc] initWithNibName:@"Photos" bundle:nil];
[self.navigationController pushViewController:photosObj animated:YES];
[photosObj release];
hoshi
  • 1,677
  • 16
  • 22