I decided to use GC for memory management for my last Cocoa project, and I found something interesting - if I create a new Cocoa application project in Xcode, turn on GC for support or it is required (I tried both), build and run it, it leaks It shows memory leaks!
Basically a large number of small leaks of objects like NSCFData, GeneralBlock, CGEvent, CFDictionary, CGSRegion, etc.
Steps to play:
- File-> new project â Cocoa application
- Project-> Change project settings-> GC Required (or one is supported)
- Build-> Build
- Run-> Run with performance tool-> Leaks
- Wait until it detects a leak (I set it to 10 seconds, by default it is 30)
In 80% of cases, I get a leak of about 2-20 Kbytes of various objects listed above.
Does anyone have any other similar behavior?
EDIT: I checked the following circumstance by renaming the InputManagers folder (after which the log messages went away so that they definitely stopped loading) and I still get memory leaks. Therefore, it seems that this has nothing to do with it. I leave the text there, so Ashley Clark's answer still makes sense.
The only strange circumstance that I know if I get the following message in the console every time I start the application 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 suppose, has something to do with the two plugins that are loaded into each running program, and not just Safari (for which they are intended for plugins). I'm not sure if there is anything or not with this, but it definitely looks like an opportunity. I don't have convenient access to clean, not OS X 10.5, with Dev tools to check if this happens on a virgin installation without SAFT or Inquisitor.