【发布时间】:2009-04-29 18:31:07
【问题描述】:
我正在开发一个 Cocoa 应用程序,在 Xcode 中运行我的应用程序时,我经常在调试控制台中收到以下类型的消息:
<My app name>(952,0xb0103000) malloc: free_garbage: 垃圾 ptr = 0x107b2f0, 非零引用计数 = 1
我打开了 MallocStackLogging 和 NSZombieEnabled 并在其中几个地址上做了 malloc_history 并得到了沿着底部引用的行的跟踪。
公共线程似乎是在所有出现错误的块中对 NSPopupButtonCell 的引用。
我的猜测是它对某处被 CFRetained 但未释放或使垃圾可收集的东西起作用。
A) 这更有可能是我的编程错误,还是框架中尚未针对 GC 正确更新的问题?
B) 引发此消息的问题的后果是什么(如果有)?即我需要注意这条消息还是可以忽略它?
调用 [2] [arg=48]:thread_a003d720 |开始 |主要 | NSApplicationMain | -[NSApplication 运行] | -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] | _DPSNextEvent | BlockUntilNextEventMatchingListInMode | ReceiveNextEventCommon | RunCurrentEventLoopInMode | CFRunLoopRunInMode | CFRunLoopRun 特定 | __CFRunLoopDoObservers | _handleWindowNeedsDisplay | -[NSWindow displayIfNeeded] | -[NSView 显示如果需要] | -[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 | CUI复制测量 | CUIRenderer::CopyMeasurements(CGRect, CGContext*,__CFDictionary 常量*, __CFArray 常量*) | CUIRenderer::CopyImageMeasurements(长, CUIContext 常量*,__CFArray 常量*, __CFDictionary*) | CreateImageSourceFromDisk(长, CUIContext const*、long*、无符号 字符*) | CUISharedArtReader::CreateImageSource(long) | CGImageSourceCreateWithDataProvider | CGImageReadCreateWithProvider | CGImageReadCreateWithData | _CGImageReadCreate | _CFRuntimeCreateInstance | CFAllocatorAllocate | auto_zone_allocate_object 调用 [4] [arg=0]:thread_b0103000 |thread_start | _pthread_start | auto_collection_thread(void*) | auto_collect_with_mode(Auto::Zone*, 无符号整数) | auto_collect_internal(Auto::Zone*, 整数)
【问题讨论】:
标签: cocoa xcode memory-leaks garbage-collection