我正在开发一个Cocoa应用程序,并且在Xcode中运行我的应用程序时经常会在调试控制台中收到以下类型的消息:

  

<我的应用名称>(952,0xb0103000)malloc:free_garbage:garbage ptr = 0x107b2f0,非零refcount = 1

我启用了MallocStackLogging和NSZombieEnabled,并在其中几个地址上执行了malloc_history,并在底部引用了这些内容。

公共线程似乎是在所有带错误的块中对NSPopupButtonCell的引用。

我的猜测是,某些地方被CFRetained但未被释放或垃圾收集。

A)这更可能是我本身的编程错误还是框架中尚未针对GC正确更新的内容?

B)引发此消息的问题的后果是什么?即我是否需要关注此消息,还是可以忽略它?

  

调用[2] [arg = 48]:thread_a003d720   |开始|主要| 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:冠捷:]   | - [的NSView   _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:冠捷:]   | - [的NSView   _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:冠捷:]   | - [的NSView   _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:冠捷:]   | - [的NSView   _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:冠捷:]   | - [的NSView   _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:冠捷:]   | - [的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(长,   CUIContext const *,__ CFArray const *,   __CFDictionary *)| CreateImageSourceFromDisk(长,   CUIContext const *,long *,unsigned   char *)|   CUISharedArtReader :: CreateImageSource(长)   | 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(自动::区*,   unsigned int)|   auto_collect_internal(自动::区*,   INT)

有帮助吗?

解决方案

它实际上是在Xcode使用的低级框架中,任何使用NSImage的垃圾收集应用程序也会生成同样的(无害但令人讨厌的)消息。

沉默这些的一种方法是: http://0xced.blogspot.com /2008/09/quietxcode.html

其他提示

我一直在使用Xcode看到这一点。这是Xcode本身的一个内存管理问题,与你的程序无关。

如果错误与您的程序有关,它们将显示在调试窗口(按shift-command-r时显示的那个)以及系统控制台中。

那些Xcode malloc消息只出现在系统控制台中,所以它们不是你的问题。

现在,这期Apple发布了一个将大量内存错误日志转储到系统控制台的IDE? 那个可能需要担心:)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top