What exactly is the purpose of using malloc hooks? And I’ve read it’s used in memory-profiling, etc. but never really understood how.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, if you can hook into the behaviour of allocation functions, then you can track memory allocations for profiling and debugging.
The GCC documentation on malloc hooks has a nice little example demonstrating adding debug output every time the allocation functions are invoked.
I’m not really sure what else to tell you… is that not reason enough?