Question

I'm developing a Cocoa app, and every so often when running my app in Xcode I get the following sorts of messages in the debugging console:

<My app name>(952,0xb0103000) malloc: free_garbage: garbage ptr = 0x107b2f0, has non-zero refcount = 1

I turned on MallocStackLogging and NSZombieEnabled and did a malloc_history on a couple of these addresses and got traces along the lines of that quoted at the bottom.

The common thread seems to be references to NSPopupButtonCell in all the blocks with the error.

My guess is that it's do to something being CFRetained somewhere but not released or made garbage collectable.

A) Is this more likely to be a programming error on my part or something in the framework that hasn't been properly updated for the GC yet?

B) What are the consequences of the issue provoking this message, if any? i.e. Do I need to pay attention to this message or can I just ignore it?

Call [2] [arg=48]: thread_a003d720 |start | main | NSApplicationMain | -[NSApplication run] | -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] | _DPSNextEvent | BlockUntilNextEventMatchingListInMode | ReceiveNextEventCommon | RunCurrentEventLoopInMode | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopDoObservers | _handleWindowNeedsDisplay | -[NSWindow displayIfNeeded] | -[NSView displayIfNeeded] | -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] | -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] | -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] | -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] | -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] | -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] | -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] | -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] | -[NSView _drawRect:clip:] | -[NSControl drawRect:] | -[NSMenuItemCell drawWithFrame:inView:] | -[NSPopUpButtonCell _drawIndicatorWithFrame:inView:] | -[NSPopUpButtonCell _indicatorFrameForCellFrame:inView:] | -[NSPopUpButtonCell _indicatorFrameForCellFrame:isFlipped:] | -[NSPopUpButtonCell _defaultIndicatorImage] | -[NSPopUpButtonCell _coreUIDefaultIndicatorImage] | +[NSImage imageNamed:] | +[NSImage _coreUIImageWithName:] | +[NSImage _coreUIImageWithBaseName:state:backgroundStyle:] | -[NSCoreUIImageRep imageWithoutEffectsRect] | SizeForImageOptions | CUICopyMeasurements | CUIRenderer::CopyMeasurements(CGRect, CGContext*, __CFDictionary const*, __CFArray const*) | CUIRenderer::CopyImageMeasurements(long, CUIContext const*, __CFArray const*, __CFDictionary*) | CreateImageSourceFromDisk(long, CUIContext const*, long*, unsigned char*) | CUISharedArtReader::CreateImageSource(long) | CGImageSourceCreateWithDataProvider | CGImageReadCreateWithProvider | CGImageReadCreateWithData | _CGImageReadCreate | _CFRuntimeCreateInstance | CFAllocatorAllocate | auto_zone_allocate_object Call [4] [arg=0]: thread_b0103000 |thread_start | _pthread_start | auto_collection_thread(void*) | auto_collect_with_mode(Auto::Zone*, unsigned int) | auto_collect_internal(Auto::Zone*, int)

Was it helpful?

Solution

It's actually in a lower-level framework used by Xcode, and any garbage-collected application that uses NSImage will also generate this same (innocuous but annoying) message.

One way to silence these is here: http://0xced.blogspot.com/2008/09/quietxcode.html

OTHER TIPS

I see this all the time with Xcode. It is a memory management problem in Xcode itself, and nothing at all to do with your program.

If the errors were related to your program, they would show up in the debugging window (the one that shows up when you press shift-command-r) as well as in the system console.

Those Xcode malloc messages come up only in the system console, so they are not your problem.

Now, this issue of Apple releasing an IDE that dumps tonnes of memory error logs into the system console? That might be something to worry about :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top