views:

46

answers:

1

Hi everyone, I'm creating one Cocoa application for myself and I found a problem. I have two NSTextFields and they're connected to each other as nextKeyViews. When I run this app with memory leaks detection tool and tab through those 2 textboxes for a while, enter some text etc., I start to leak memory. It shows me that the AppKit library is responsible, the leaked objects are NSCFStrings and the responsible frames are [NSEvent charactersIgnoringModifiers] and [NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]. I know this is quite a brief and incomplete description, but does anyone have any ideas what could be the problem?

Also, I don't use GC, so I release my instance variables in the controllers dealloc. What about the outlets? Since IBOutlet is just a mark for Interface Builder and doesn't actually mean anything, should I release them too?

+1  A: 

What about the outlets? Since IBOutlet is just a mark for Interface Builder and doesn't actually mean anything, should I release them too?

Your declaration of the IBOutlet tells you how to manage it... If you declare it as retained and then @synthesize it, the process of loading the nib will retain the outlet. Therefore you must release it.

Andiih coined the mnemonic NARC

NARC: "New Alloc Retain Copy". If you are not doing any of those things, you don't need to release.

The corollary is also true.. if you do any of those, you are responsible for releasing the object at the appropriate time.

ohhorob