0

What can be the reason of memory leaks that originating when I push back to previous view (Navigation Based Application)?

enter image description here

Edited: code added

- (void)viewDidUnload
{
[self setTableView:nil];
[super viewDidUnload];
[self setSearchController:nil];
[self setSearchBar:nil];
toolBar=nil;
}
- (void)dealloc
{
[tableView release];
[searchBar release];
[_toolBar release];
[nominalsArr release];
[searchController release];
[filteredItems release];
[super dealloc];
}

Another edit

enter image description here

NCFUSN
  • 1,624
  • 4
  • 28
  • 44
  • When you push back the last controller is released and probably dealloced, you must be forgetting a release... Can you post the controller code? – fbernardo Mar 02 '12 at 00:59
  • @ fbernardo Hello, thank you much for yesterday's help. Please, see edit. – NCFUSN Mar 02 '12 at 01:12
  • No problem, what about the code related to the image? – fbernardo Mar 02 '12 at 01:13
  • @fbernardo nominalsArr is capsula in which I store data retrieved from DB. It's retained and I release it in dealloc meth. self.nominalsArr=[dbAccsess returnNominals:subCountryID]; – NCFUSN Mar 02 '12 at 01:16
  • Use data in custom cell class in drawRect method: NSString *filePath = [[NSBundle mainBundle] pathForResource:theNominal.nominalImg ofType:@"png"]; – NCFUSN Mar 02 '12 at 01:19
  • Hmm, instruments shows you 3bytes, that's very small, like a char* or something... I would start by replacing or commenting out all the "outside" of the controller class calls and testing if it still hapens. – fbernardo Mar 02 '12 at 01:20
  • " I would start by replacing or commenting out all the "outside" of the controller class calls and testing if it still hapens ". What do you mean? – NCFUSN Mar 02 '12 at 01:24
  • By the way... I'm calling DB method in ViewWillAppear of controller – NCFUSN Mar 02 '12 at 01:26
  • For example, if you have anything that is created outside the class, a object, a char*, anything. Try to isolate the problem, something like "hey, if i don't call strdup here it won't leak...". – fbernardo Mar 02 '12 at 01:27
  • Wait, show me the sqlNominals property declaration and your returnNominals method. – fbernardo Mar 02 '12 at 01:29
  • There's strange that leak happens Only when I hit back... – NCFUSN Mar 02 '12 at 01:29
  • That's because the navigation controller is deallocing your controller. – fbernardo Mar 02 '12 at 01:30
  • When a release s called retain count goes dow not up, so -1 – fbernardo Mar 02 '12 at 01:33
  • In my case looks like +1. See another edit – NCFUSN Mar 02 '12 at 01:38

1 Answers1

0

By your last image what's happening is:

  • you are allocing and then autoreleasing a NSString

  • then you are assigning it to a retain property, that guess what, retains it (retain count +1)

  • then you are not releasing it and appparently can't access it anymore (leaked)

fbernardo
  • 10,016
  • 3
  • 33
  • 46
  • Well, the strings are not leaking anymore, there's another problem at moment. http://stackoverflow.com/questions/9544846/ios-memory-leak-in-simple-mvc-model . Anyway, meanwhile you helped me. thanks. – NCFUSN Mar 03 '12 at 09:13