And then there is glibc's malloc():
A very good place to start is Mr. Golick's intro: Memory Allocators 101, then there is Mr. Luu's C tutorial, or even Doug Lea's dlmalloc. But, that's only the beginning of a very good, very long story.
Strategies (the very meat of this post):
There is an interesting survey on the different ways of writing a memory allocator, it's very informative (and well-written), and useful to know in general (even though it's a little old).
More Specific:
For even more pleasing (and productive) confusion, there's TCMalloc, Lockless and a short paper that compares glibc to the former and the latter.
Also notable is jemalloc, and they have a nice video too. Here's a neat synopsis of this toy.
Profiling:
TCMalloc has profiling inbuilt (via perftools), Lockless has some hooks and jemalloc has a heap profiler. If you want to check what glibc malloc gets up to, there's malloc_count, or, you can knit your own, using malloc hooks and struct mallinfo.
The Lockless site has some neat info on how to profile without a profiler, using gcc. (their article collection is also quite a good read [with a very special recommendation for the rather nifty 'Obfuscated Rogue' proggy <3 !]).
Happy alloc()-ing!
Ps.: Stuff I idly wonder about:
None of the above seem to take performance profiles of stuff as they run and then automate the conclusions.
There is probably a very good reason for it (there always is :-) --- but, I wonder what would happen if we had a wrapper that that 'kept score' and did test runs on the inputs it knows about and then swaps in different memory allocators on the next run, depending on what profiles match that particular usage pattern the best.
+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
Happy New year everyone!!!