Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > MallocDebug?

MallocDebug?
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Apr 7, 2003, 12:01 PM
 
I have an application that I think is slowly leaking memory. It runs great for a about an hour and then quits unexpectedly. Does MallocDebug allow me to watch the memory allocation for various objects? Can someone give me a quick primer to get me started? I don't have a clue what I am doing, but I launched the app and tried Attach... but it told me there were no apps running with attach code or something. Any help would be appreciated.

thanks,
kman
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Apr 7, 2003, 12:07 PM
 
Okay, I read the help to get me started. I chosed my app and hit launch. It crashes immediately even though this doesn't happen when I launch the app by itself. Here's the crash dialog from Malloc:

/F@HMonitor/build/F@HMonitor.app/Contents/MacOS/F@HMonitor accessed memory at 0x7c0802ae illegally.

kman
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Apr 7, 2003, 02:46 PM
 
MallocDebug turns on some extra debugging options that try to make malloc crash immediately if there's a problem with your code. The reason for this is that memory errors usually suck to track down since the crash will often take place very far from the problem (it took me 5 eight hour days to track one of these down last week).

From the command line, do something like this:

Code:
% cd <path to your executable>/Contents/MacOS/<your executable name> % gdb <your executable name> (gdb) set env MallocScribble 1 (gdb) set env MallocGuardEdges 1 (gdb) set env MallocStackLogging 1 (gdb) set env MallocCheckHeapStart 1000 (gdb) set env MallocCheckHeapEach 1000 (gdb) run <your code will crash after spewing out some messages> (gdb> bt
This'll show you where your code is dying. More info here.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2