How Do You Enable Memory Leak Detecting In Xcode?

Discussion in 'Mac Programming' started by bobber205, Apr 25, 2007.

  1. bobber205 macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #1
    In Visual studio you use:

    Code:
    #define _CRTDBG_MAP_ALLOC
    
    //then after main
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
    
    
    This does not compile in Xcode.
    Launch Using Performance Tool --> Malloc does not work b/c I am using the new operators with C++.

    EDIT:

    When I purposely try to go over an array's bounds, I get "executable path is nil". What does this mean?

    Thanks! :D
     
  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    Those flags are definitely a Windows or Visual Studio only feature.

    As far as debugging memory leaks on a Mac, take a gander at this:

    http://www.cocoadev.com/index.pl?MemoryLeaks

    Some of it is Cocoa/Objective-C specific, but a lot of it isn't.
     
  3. GothicChess.Com macrumors regular

    GothicChess.Com

    Joined:
    Apr 6, 2007
    Location:
    Philadelphia, PA
    #3

    I am not sure what you mean by "Malloc does not work..."

    malloc() almost always works if you have enough RAM to support what you are malloc-ing! Are you trying a data type conversion on what you are malloc-ing, or just asking for a chuck of memory?

    Trying to create range-checking errors on purpose is not a sign of bravery... that is usually the quickest way to crash, do not "Pass Go" or collect $200, go straight to Crash City, enjoy your stay...

    I work with malloc() day in and day out, so if I knew more about what you were trying to do, I might be able to help.
     
  4. bobber205 thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #4
    I didn't mean the Malloc function in general. ;)

    I meant the Tool That's called MallocCheck or something like that. :D
     
  5. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #5
    Could I suggest that instead of asking the poor folks at MacRumors you get the information from the horses mouth?

    Go to www.apple.com.
    Click on "Developer"
    Type "memory leak" into the search box.
     
  6. Krevnik macrumors 68030

    Krevnik

    Joined:
    Sep 8, 2003
    #6
    If I recall correctly, the new operator calls into malloc() at some point, so MallocCheck should still work.
     
  7. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
  8. Thomas Harte macrumors 6502

    Joined:
    Nov 30, 2005
    #8
    Are you looking for Guard Malloc? To enable it, just tick "Enable Guard Malloc" at the bottom of the Debug pull-down menu in the menu bar. Then do a "Build and Debug" (i.e. command+Y) from the build menu...
     

Share This Page