I want to use TCMalloc with STL containers, so I need an allocator built with TCMalloc (like tbb_allocator with TBB malloc). I cannot find any anything TCMalloc documentation (if it is called a documentation). So I start to explore the header files and find a class called STL_Allocator
. But something is not clear to me. Quotation from stl_allocator.h :
// Generic allocator class for STL objects
// that uses a given type-less allocator Alloc, which must provide:
// static void* Alloc::Allocate(size_t size);
// static void Alloc::Free(void* ptr, size_t size);
//
// STL_Allocator<T, MyAlloc> provides the same thread-safety
// guarantees as MyAlloc.
//
// Usage example:
// set<T, less<T>, STL_Allocator<T, MyAlloc> > my_set;
// CAVEAT: Parts of the code below are probably specific
// to the STL version(s) we are using.
// The code is simply lifted from what std::allocator<> provides.
And the definition of STL_Allocator template class is:
template <typename T, class Alloc>
class STL_Allocator {
//...
}
I have no idea what that Alloc
argument could be. Am I supposed to write a wrapper class for some memory allocation functions? Anyone used TCMalloc?