1

I can't understand this behaviour in my app and I'm seriously thinking burn my mac NOW and start writing books of stories for children.

enter image description here

enter image description here

I have a normal Navigation Controller, and i push and pop viewcontrollers from it.

I'm doing a basic transition between views and I'm realising everything that I'm retaining or copying or whatever. But Instruments STILL identifies abandoned memory, and says that line is the responsible for that. I can't understand. What I'm forgetting? In Area2 I have few outles and one UIImageVIew, do I need to realising them to, in some way?

One more thing, if use Leaks inspector that same line is identified as a leak.. Really, I'm capable to destroy de entire world!

Please, can someone help me and tell me what I'm doing wrong and / or forgettting?

( Iniatly I had self.navigationController instead of delegate.navigationController, but the problems occurs to! )

Just this:


    #import 

    @interface Area2 : UIViewController
    {
        IBOutlet UIButton * btBack;
    }

    # pragma mark - Navigation Controller
    - (IBAction)goBack:(id)sender;
    - (IBAction)goGaleria:(id)sender;

When I do Analyze ( Menu: "Product"->"Analyze" Xcode 4.2 ) give me build succeeded!

UPDATE:

SOLUTION is in the replies at @mit3z's answer! @babbidi answer!

1 Answers1

1

If you have your outlets as properties and you don't release them in dealloc - then yes, you'll get a leak. It's hard to tell without seeing Area2 @interface declaration.

ksh
  • 1,894
  • 19
  • 20
  • I don't see UIImageView in your declaration at all, can you post some code where you're using/creating it? – ksh Feb 08 '12 at 13:33
  • I don't have a reference to it in code, because it's just holding a image in xib file. Background image purpose only! http://i43.tinypic.com/29awghv.png As you can see I have some buttons to, just with an IBAction and image defined in the IB. – Fábio Azevedo Feb 08 '12 at 13:38
  • OK, i don't see any problems with your code, and since you're looking at heapshots : how do you record them, what happends if you wait a minute? does that heap growth goes away? Run Leaks instrument, does it show any leaks too? – ksh Feb 08 '12 at 13:43
  • I just want to add that also outlets without properties need releasing (in this case `btBack` should be released), presuming we're talking about iOS. More info: http://stackoverflow.com/questions/1221516/does-an-iboutlet-needs-to-be-a-property-synthesized – alex-i Feb 08 '12 at 14:21
  • I go to Area 2 and back, mark heap as baseline, then repeat the process, go - back - mark, and the results is similar to what is in the image above. Yes sometimes identifies leaks to. Here a screenshot. Seriously I'm going insane. I can't understand the behaviour. Here an image with some leaks that Instruments reports when I navigate. See if anything is familiar to you http://i40.tinypic.com/2isbp74.png and the line wich is identified as the problem, again: http://i44.tinypic.com/fkmb74.png – Fábio Azevedo Feb 08 '12 at 14:27
  • Try releasing 'btBack' in dealloc, IBOutlets are retained in iOS. – ksh Feb 08 '12 at 14:40
  • mit3z and @babbidi really thanks! That's solve the problem! Now it's just identify this as a leak: NSDictionary * dict = [[NSDictionary alloc] initWithContentsOfFile: path]; data = [[NSArray alloc] initWithArray:[dict objectForKey:@"galeria"]]; [dict release]; One more time, it's something strange, because I do the release of the dict, and in dealloc I release the data. If it's something familiar to you and you could help, nice, I'll google it anyway! – Fábio Azevedo Feb 08 '12 at 15:29
  • @FábioAzevedo unless you call that block of code multiple times after initialization (alloccing `data` multiple times and releasing it just once on dealloc), it looks fine – alex-i Feb 08 '12 at 15:32
  • @babbidi you're right! My bad! Sorry guys! I wasn't releasing data in dealloc! Now it's great! Again, thanks for your time! – Fábio Azevedo Feb 08 '12 at 15:41