• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fun with MallocDebug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fun with MallocDebug


  • Subject: Fun with MallocDebug
  • From: Hua Ying Ling <email@hidden>
  • Date: Wed, 3 Jul 2002 22:02:44 -0400

I have a couple of questions about MallocDebug usage:

I wrote a simple test program(listed below) to experiment with MallocDebug.
Why doesn't Malloc debug show the DoLeak function as a leak?

//=================
void DoLeak( void ) {
char * temp = malloc(10);
memcpy(temp, "time", 4);
}

int main (int argc, const char * argv[]) {

DoLeak();

while(TRUE) { // keep app running for malloc debug
}

return 0;
}
//==================

I'm also trying to find which line of my program is causing MallocDebug to print debugging statements such as you have a double free or you tried to free a non malloced block.

I've linked the program using the "-flat_namespace" option and issued the following commands in GDB listed below, but the debugger never breaks.

//==================
<gdb> set start-with-shell 0
<gdb> set env DYLD_INSERT_LIBRARIES /usr/lib/libMallocDebug.A.dylib
<gdb> set env DYLD_FORCE_FLAT_NAMESPACE 1
<gdb> attach process-id
<gdb> b malloc_printf
//==================

I also wrote a simple cocoa program to test this, it has just one action:

//==================
- (IBAction)leak:(id)sender
{
char * temp = malloc(10);
free(temp + 2);
}
//==================

I was hoping I could get the debugger to break when I tried to free an invalid block on the second line, by setting a break at malloc_printf.

If it makes a difference, I'm using the Jaguar tools.
Any suggestions would be appreciated.
~Hua Ying
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Fun with MallocDebug
      • From: Dan Crevier <email@hidden>
  • Prev by Date: Re: Cocoa stripping resource forks: does Jaguar fix?
  • Next by Date: Re: How to make my application quit?
  • Previous by thread: Re: how would you allow editing of a combo box's values?
  • Next by thread: Re: Fun with MallocDebug
  • Index(es):
    • Date
    • Thread