1

My application starts in a certain view and from there the user can push through several views. When the user reaches the last view I have provided a button to pop to the rootview controller.But the memory which has been increasing through out the application when each view is pushed, is found to be unreleased. And again if the user starts using the application it keeps increasing. I dunno where the problem actually lies. Can somebody please help me out of this ??

-(void)buttonPressedStart{
    QuizicleViewController *dvController = [[QuizicleViewController alloc] init];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Cancel" style: UIBarButtonItemStyleBordered target: nil action:nil];
    [[self navigationItem] setBackBarButtonItem: backButton];
    [backButton release];
    [self.navigationController pushViewController:dvController animated:YES];
    [dvController release];
    dvController = nil;
}
Abizern
  • 146,289
  • 39
  • 203
  • 257
stack2012
  • 2,146
  • 2
  • 16
  • 23
  • 1
    Perhaps. But not without seeing some code. For instance, are you using a UINavigationController, I hope? – PengOne Jun 22 '11 at 04:45
  • Can you show us how you are pushing new controllers? – EmilioPelaez Jun 22 '11 at 04:45
  • Are you using the dealloc method to release memory? Have you tried using the instruments, specifically the Leaks tester? – Joe Jun 22 '11 at 04:48
  • @PengOne yeah I use navigation controller only.... – stack2012 Jun 22 '11 at 04:55
  • @Deepmist Yes I use dealloc to release memory. I chked with instruments Leaks and it shows that memory keeps increasing and never drops to down to inital value when i come back to where i started. – stack2012 Jun 22 '11 at 04:56
  • @Deepak raj Do you call `dealloc` directly? It's hard to tell without seeing some code. Wasn't `Leaks` helpful in identification? – Deepak Danduprolu Jun 22 '11 at 05:04
  • @Deepak I release all my objects and allocated arrays in dealloc method for each view. Leaks wasnt showing any leaks but the memory keeps increasing. Where the problem could lie possibly ? – stack2012 Jun 22 '11 at 05:11
  • Hmm... do you load images using `imageNamed:`? – Deepak Danduprolu Jun 22 '11 at 05:13
  • No i dont use images. Actually am developing a quiz app where i show the questions to the user continously and then at the end of the quiz the user can push to next view to see the results and the from there to the next view where the user has to enter his name email etc and submit. From there the user has a provision to get back to rootview. And tat s where my problem lies. The memory s not dropping to initail value but remains the same as it got increased when pushing thru each view.... – stack2012 Jun 22 '11 at 05:17
  • Can any one please help me out of this ? Actually I have almost finished the app except for this memory problem. – stack2012 Jun 22 '11 at 05:22
  • First of all, test on a device because the Simulator behaves differently. Then use the Leaks tool to find out where the memory is leaking. – Mike Weller Jun 22 '11 at 05:49
  • Unfortunately no one can actually help you with this given the vague description you have provided. You might be leaking objects. You might just be retaining them forever. We can tell because we can't see your code from here. You need to provide some kind of example of what you are doing and what your unexpected result it before there's any chance we can spot what you are doing wrong. – Jonah Jun 22 '11 at 05:55
  • Do you retain your view controllers? If so then you got a problem here. – Praveen S Jun 22 '11 at 07:56
  • @Praveen No i dont retain any of my view controllers I just push them and at the end i pop to root view.... – stack2012 Jun 22 '11 at 08:31
  • If you use UINavigationController you use pushViewController:animated:, popViewControllerAnimated:, and popToRootViewControllerAnimated: right? – gsempe Jun 22 '11 at 08:36
  • Other questions: is your data provider one of your UIViewController? When you push your UIViewController you follow the sequence alloc+init - push - release? – gsempe Jun 22 '11 at 08:46
  • Yeah i follow tat sequence only for pushing. Yeah my first view holds an array which is used through tat view and subseqeunt view has got its own arrays and other allocations but i release them all in dealloc.But I retain the array in the first view and release it. – stack2012 Jun 22 '11 at 08:53
  • I delete my answer because it was useless. – gsempe Jun 22 '11 at 09:08
  • Why dont you paste some of the code? Where you push view controllers etc. – Praveen S Jun 22 '11 at 09:16
  • Can anyone please help me out of this ? I cant post the code. Because I have arnd 4 views wid lot of code. – stack2012 Jun 22 '11 at 09:18
  • @Praveen I have pasted some code...Please tell me if u want some other part of my code. I want to solve this problem anyhow... Please help me :( – stack2012 Jun 22 '11 at 09:30
  • Try setting a break point, or putting an NSLOG in your view controllers dealloc method and see if it is ever getting called. – Joe Jun 22 '11 at 23:09
  • @Deepmist I checked by setting break points and I found that dealloc of the root view alone is not being called. Except that all the other views deallocs are called. – stack2012 Jun 23 '11 at 04:42

1 Answers1

0

Due to my less reputation i have to add an answer. The same thing happened to me a little while ago. I was pushing a view controller and then releasing it but the dealloc method was not called. Then after a little debugging i realized that i was doing some work on a separate thread and i was releasing the view without the thread getting complete. As the thread was still running the dealloc method will not be called. I dont know if this is the case with you but if you have used multi threading please check if its the case.

iAmd
  • 812
  • 1
  • 12
  • 22