I'm new to this forum and I have searched but not found any answers to this problem which has been puzzling me for best part of this week.
An NSTextField causes a memory leak every time a key is pressed.
I have isolated this problem from my code and it can be reproduced as follows:
- Create a new "Cocoa Application" project.
- Place an NSTextfield in the main menu xib window. (No Binding, Outlet or Action)
- Product -> Profile, choose "memory leak" instrument (in XCode 4)
No leaks until the user enters a character in the text field. I get 8 leaked NSCFString objects of 32bytes of the following types:
Library Responsible Caller 0 CFString Malloc 00:11.524.538 1 0x100130bb0 32 AppKit -[NSEvent charactersIgnoringModifiers] 1 CFString Malloc 00:11.622.145 1 0x100136950 32 AppKit -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
Please note that this project has no code other than the auto generated stuff.
I would be interested if anyone else can reproduce this problem and maybe even offer a suggestion how to prevent it from occuring.
OS X 10.6.8 with XCode 4.0.2 (same problem occurs with with 3.2.6)
Any suggestion would be greatly appreciated and would decrease my current level of frustration.
Update:
Tried the above project creation on different macs. Found that one of them produces no leaks (using the same procedure as above to create project) Installed XCode 4 on a mac that never had XCode installed - no leaks!
- Unistalled Xcode3.2.6 on fairly new MBPro using this procedure: http://macdevelopertips.com/xcode/how-to-uninstall-xcode.html
- Re-Installed XCode4
STILL LEAKING MEMORY.
- Erased the HDD on same MPro, installed OS X 10.6, software update to 10.6.8
- installed XCode4
- created same test project as above
NO MEMORY LEAKS!!!!!
It is now clear that the root of this problem is somewhere in the installation and not just a "False Positive" of Instruments. My profile runs were executed multiple times so there is being a one-off and the behaviour was 100% re-producable on my macs.
Problem now: I still have a 27" iMac where HDD erase is not an option. I'm guessing that there is something installed (Framework?) that doesn't get updated/deleted when upgrading or reinstalling XCode.
Your ideas on the cause of this issue are greatly appreciated.