I decided to use the GC for memory management for my latest Cocoa project, and I discovered something interesting--if I create a brand new Cocoa app project in Xcode, turn GC to supported or required (I tried both), build, and run it it leaks, it shows memory leaks!
Mostly large numbers of tiny leaks of objects of type NSCFData, GeneralBlock, CGEvent, CFDictionary, CGSRegion, etc.
Steps to reproduce:
- File->new project->Cocoa app
- Project->Edit Project settings->GC Required (or supported, either one)
- Build->Build
- Run->Run with performance tool->Leaks
- Wait for leak detection to trigger (I have it set to 10 secs, it defaults to 30)
80% of the time or so I get a leak of around 2-20 Kb of various objects of the sort listed above.
Does anybody else have this same behavior?
EDIT: I tested the below circumstance by renaming the InputManagers folder (at which point the log messages went away, so they were definitely no longer being loaded) and am still getting the memory leaks. So it doesn't seem likely that had anything to do with it. I'm leaving the text there so Ashley Clark's answer still makes sense.
The only odd circumstance I know if is I'm getting the following message in the console any time I run an app with GC enabled:
2008-12-12 13:03:09.829 MemLeakTest[41819:813] Error loading /Library/InputManagers/Inquisitor/Inquisitor.bundle/Contents/MacOS/Inquisitor: dlopen(/Library/InputManagers/Inquisitor/Inquisitor.bundle/Contents/MacOS/Inquisitor, 265): no suitable image found. Did find:
/Library/InputManagers/Inquisitor/Inquisitor.bundle/Contents/MacOS/Inquisitor: GC capability mismatch
2008-12-12 13:03:09.840 MemLeakTest[41819:813] Error loading /Library/InputManagers/Saft/SaftLoader.bundle/Contents/MacOS/SaftLoader: dlopen(/Library/InputManagers/Saft/SaftLoader.bundle/Contents/MacOS/SaftLoader, 265): no suitable image found. Did find:
/Library/InputManagers/Saft/SaftLoader.bundle/Contents/MacOS/SaftLoader: GC capability mismatch
which I'm guessing has something to do with those two plug-ins trying to load into every single program that starts, not just Safari (which they're plug-ins for). I'm not sure if that has anything do do with this or not, but it definitely seems like a possibility. I don't have convenient access to a clean instead of OS X 10.5 with Dev tools to test whether or not this same thing happens on a virgin install without SAFT or Inquisitor.