• 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
Re: Documentation on Guard Malloc system level interface?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Documentation on Guard Malloc system level interface?


  • Subject: Re: Documentation on Guard Malloc system level interface?
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 8 Jan 2011 18:51:08 -0600

On Jan 8, 2011, at 6:13 PM, Yuri wrote:

> I know Guard Malloc has the capability to capture all memory allocations and doesn't require other libraries to be explicitly linked to it.
> Here http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html is its user-side interface.
> Where can I find its system-side interface? How does it get malloc calls?

It's not "capturing" memory allocations.  It "gets" malloc calls by being the malloc library.  It is directly called by anything trying to allocate memory.  The documentation you linked to explains it:

"Guard Malloc is a special version of the malloc library that replaces the standard library during debugging."

There's a link to the libgmalloc man page.  There it explains the use of DYLD_INSERT_LIBRARIES as:

"This tells dyld to use Guard Malloc instead of the standard version of malloc."


> I am trying to understand how can google-perftools malloc library be made to do the same.

I assume that's also a replacement malloc library (instead of being an alternative that is loaded in addition to the standard malloc library and has to be used explicitly by the code.)  If so, then it's already in a position to do the same, but has to be coded to do so.  It would have to put each allocation on a separate VM page and use mprotect() or vm_protect() to set the page after (or before, depending on configuration) as a guard page.  Given the name, with "perftools" in there, I strongly suspect that's counter to the purpose of that library.

Why are you trying to use both?  Use one or the other for the need of the moment.  That is, Guard Malloc is not intended to be used on any permanent basis.  It's just used during debugging, to try to find memory-related bugs in your code.  So, when you're debugging those sorts of issues, use it and not the google-perftools library.  Otherwise, use the google-perftools library.

Regards,
Ken

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Documentation on Guard Malloc system level interface?
      • From: Yuri <email@hidden>
References: 
 >Documentation on Guard Malloc system level interface? (From: Yuri <email@hidden>)

  • Prev by Date: Re: Why isn't Interface Builder showing any classes from my project?
  • Next by Date: Re: Why isn't Interface Builder showing any classes from my project?
  • Previous by thread: Documentation on Guard Malloc system level interface?
  • Next by thread: Re: Documentation on Guard Malloc system level interface?
  • Index(es):
    • Date
    • Thread