简体   繁体   中英

Debugging memory leaks with libMallocDebug

I want to use the MallocDebug app to find some memory leaks in my app. I'm running Mac OS X 10.6.2. Whenever I try and following the instructions listed in this guide , I get the following error:

dyld: could not load inserted library: /usr/lib/libMallocDebug.A.dylib

Trace/BPT trap

I have verified that the .dylib file exists, and I get the same error no matter which app I try and run (it's not limited to my application). Several others have reported this problem as well, but so far no one has found a solution.

Any ideas?

libMallocDebug is not available for 64-bit executables.

% lipo -info /usr/lib/libMallocDebug.A.dylib    
Architectures in the fat file: /usr/lib/libMallocDebug.A.dylib are: i386 ppc7400 

It does appear to work with 32-bit executables in 10.6, though, for example:

% lipo -thin i386 /bin/ls -out foo
% DYLD_INSERT_LIBRARIES=/usr/lib/libMallocDebug.A.dylib ./foo        
libMallocDebug[foo-9141]: initializing libMallocDebug on thread 903
[...]

I'm not sure whether this is an oversight or it was never ported to the 64-bit runtime. You might try filing a bug.

Update: Seems there are just more debugging features in the regular malloc now. This discussion is pretty good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM