Re: Difficulties with MallocDebug
Ken Ferry <[email protected]> Sat, 8 Jan 2011 22:07:24 -0800
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Christopher, I don't know what exactly the problem is, but I have a suggestion: Use Instruments for leak checking, or the command line tool leaks. The document you linked to probably needs an update. It's misleading to give MallocDebug equal time. That tool is on its way out, and is not well maintained. -Ken Cocoa Frameworks On Sat, Jan 8, 2011 at 8:43 PM, Christopher Henrich <chenrich-I/mPKdbEGRBWk0Htik3J/[email protected]>wrote: > I am having trouble using MallocDebug to look for memory leaks in a program > that I am developing. > > The program mixes Cocoa and Objective-C with C++. The relevant part of it > implements a gnarly algorithm to count certain subsets of a graph. When the > graph gets large, the algorithm seems to use an awful lot of heap space. I > suspect that I have a memory leak. But "suspect" isn't "know," and I would > like to get some data about heap usage. > > MallocDebug would appear to be my friend. The Mac OS X 10.6 documentation > ("Memory Usage Performance Guidelines") tells me how I can use it to examine > heap allocation and sniff out leaks. > > But I can't. When I try to launch my program from MallocDebug, my program > instantly crashes. Then MallocDebug crashes too. > The crash is bad enough that windows pop up, promising to send the details > of the crash to Apple. At the same time, MallocDebug posts a message box of > its own, stating that it is "Unable to read malloc information from (null)". > > Whatever it is that hits the fan, it does so in the execution of standard > setup code of the user interface. Evidence for this claim is found in the > following text that is supposedly(*) being sent to Apple. > > Process: StarMaker [13286] > Path: /Users/chris/Documents/Workspace/New > StarMaker/build/Release/StarMaker.app/Contents/MacOS/StarMaker > Identifier: com.mathinteract.StarMaker > Version: ??? (1.0) > Code Type: X86 (Native) > Parent Process: MallocDebug [13277] > > Date/Time: 2011-01-08 23:06:52.660 -0500 > OS Version: Mac OS X 10.6.5 (10H574) > Report Version: 6 > > Interval Since Last Report: 108452 sec > Crashes Since Last Report: 8 <<<<------------------ This makes > me paranoid > Per-App Interval Since Last Report: 37439 sec > Per-App Crashes Since Last Report: 4 > Anonymous UUID: E3F85D4F-BE81-4201-B8D6-A626804D10D0 > > Exception Type: EXC_BAD_ACCESS (SIGBUS) > Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000 > Crashed Thread: 0 Dispatch queue: com.apple.main-thread > > Thread 0 Crashed: Dispatch queue: com.apple.main-thread > 0 com.apple.CoreFoundation 0x95520293 CFQSortArray + 259 > 1 com.apple.CoreFoundation 0x95501019 CFArraySortValues + 489 > 2 com.apple.ColorSync 0x95634bc0 > ColorSyncProfileCopyTagSignatures + 175 > 3 com.apple.ColorSync 0x95661218 CMMProfile::Usable() + > 62 > 4 com.apple.ColorSync 0x95660b5d DoValidateProfile + 74 > 5 com.apple.ColorSync 0x95660c75 AppleCMMValidateProfile > + 28 > 6 com.apple.ColorSync 0x95635e52 ColorSyncProfileVerify + > 31 > 7 libCSync.A.dylib 0x90868c80 validateProfile + 65 > 8 libCSync.A.dylib 0x90868be5 CMSValidateProfile + 60 > 9 com.apple.CoreGraphics 0x94c39c4c > CGCMSInterfaceValidateProfile + 27 > 10 com.apple.CoreGraphics 0x94c39c2c > CGCMSUtilsValidateProfile + 24 > 11 com.apple.CoreGraphics 0x94c39b2b > CGColorSpaceCreateICCBased + 136 > 12 com.apple.CoreGraphics 0x94c38ee3 > create_generic_color_space + 127 > 13 com.apple.CoreGraphics 0x94c38c72 > CGColorSpaceCreateWithIndex + 298 > 14 com.apple.AppKit 0x95b457c1 +[NSColorSpace > specialColorSpaceWithID:] + 193 > 15 com.apple.AppKit 0x95b456f8 +[NSColorSpace > genericRGBColorSpace] + 45 > 16 com.apple.AppKit 0x95b4550a -[NSBitmapImageRep > _bitmapImageRep_setColorSpaceName:] + 55 > 17 com.apple.AppKit 0x95e13ccd -[NSBitmapImageRep > initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:] > + 513 > 18 com.apple.AppKit 0x95b44f9a -[NSBitmapImageRep > _initWithSharedBitmap:rect:] + 302 > 19 com.apple.AppKit 0x95b44bea -[NSImage > _addRepresentationWithSharedKitWindow:rect:] + 224 > 20 com.apple.AppKit 0x95b439f2 +[NSImage > _findSystemImageNamed:] + 274 > 21 com.apple.AppKit 0x95b43734 +[NSImage imageNamed:] + > 171 > 22 com.apple.AppKit 0x95b435d6 -[NSCustomResource > _loadImageWithName:] + 58 > 23 com.apple.AppKit 0x95b4350a -[NSCustomResource > loadImageWithName:] + 49 > 24 com.apple.AppKit 0x95b42a4b -[NSCustomResource > awakeAfterUsingCoder:] + 365 > 25 com.apple.Foundation 0x936f6524 _decodeObjectBinary + > 2930 > 26 com.apple.Foundation 0x936f5800 _decodeObject + 180 > 27 com.apple.AppKit 0x95b4225b -[NSMenuItem > initWithCoder:] + 1546 > 28 com.apple.Foundation 0x936f6508 _decodeObjectBinary + > 2902 > 29 com.apple.Foundation 0x936f5800 _decodeObject + 180 > 30 com.apple.AppKit 0x95b3db34 -[NSNibConnector > initWithCoder:] + 440 > 31 com.apple.AppKit 0x95b3d96d -[NSNibOutletConnector > initWithCoder:] + 384 > 32 com.apple.Foundation 0x936f6508 _decodeObjectBinary + > 2902 > 33 com.apple.Foundation 0x936f7314 -[NSKeyedUnarchiver > _decodeArrayOfObjectsForKey:] + 1438 > 34 com.apple.Foundation 0x936f7981 -[NSArray(NSArray) > initWithCoder:] + 586 > 35 com.apple.Foundation 0x936f6508 _decodeObjectBinary + > 2902 > 36 com.apple.Foundation 0x936f5800 _decodeObject + 180 > 37 com.apple.AppKit 0x95b3cbca -[NSIBObjectData > initWithCoder:] + 2337 > 38 com.apple.Foundation 0x936f6508 _decodeObjectBinary + > 2902 > 39 com.apple.Foundation 0x936f5800 _decodeObject + 180 > 40 com.apple.AppKit 0x95b3c194 loadNib + 161 > 41 com.apple.AppKit 0x95b3b5ed +[NSBundle(NSNibLoading) > _loadNibFile:nameTable:withZone:ownerBundle:] + 228 > 42 com.apple.AppKit 0x95b3b4fe +[NSBundle(NSNibLoading) > loadNibFile:externalNameTable:withZone:] + 158 > 43 com.apple.AppKit 0x95b3b449 +[NSBundle(NSNibLoading) > loadNibNamed:owner:] + 383 > 44 com.apple.AppKit 0x95b3824d NSApplicationMain + 434 > 45 com.mathinteract.StarMaker 0x000036c9 start + 53 > > Thread 1: > 0 libSystem.B.dylib 0x986850fa mach_msg_trap + 10 > 1 libSystem.B.dylib 0x98685867 mach_msg + 68 > 2 libMallocDebug.A.dylib 0x000e139f exceptionThread + 155 > 3 libSystem.B.dylib 0x986b285d _pthread_start + 345 > 4 libSystem.B.dylib 0x986b26e2 thread_start + 34 > > Have I left out something that I am supposed to do, in any program that is > to be examined by MallocDebug? > > (*) I am not entirely trustful of this notification mechanism. It looks so > slick and convenient, but is it really? Up near the top of that report, see > the line about "Crashes since the last report." I thought I had been > reporting all the crashes as they happened. This mechanism is supposed to be > doing that. The number of "crashes since the last report" should be 1 (or 0, > maybe). Why is it 8? > From the Help button on the reporting window I find that I should enable a > preference in the Console utility to have these reports sent automatically. > That preference is enabled. > > The smart money says that I am screwing up something. Can anybody point me > towards finding out what it is? Heartfelt thanks in advance. > > Christopher Henrich > chenrich-I/mPKdbEGRBWk0Htik3J/[email protected] > mathinteract.com > > > > > _______________________________________________ > MacOSX-dev mailing list > [email protected] > http://www.omnigroup.com/mailman/listinfo/macosx-dev >