I am trying to implement my own memory allocation code which is simple yet efficient. Any idea where I can start from. What algorithm gcc uses?
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.
This is a problem that has been examined and implemented hundreds of times; chances are your implementation is going to work in a very specific situation and nowhere else. Before spending an extraordinary amount of time attempting to solve this problem yourself, consider existing implementations that beat gcc’s generalized allocation mechanism:
http://goog-perftools.sourceforge.net/doc/tcmalloc.html
http://www.canonware.com/jemalloc/
You could also review the implementation of GCC / glibc itself by reviewing the source releases:
http://gcc.gnu.org/releases.html
http://ftp.gnu.org/gnu/glibc/
Malloc is part of the GNU C Library implementation.