Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: All
May 22, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Better Alternatives to a Custom Memory Manager

Some applications have special memory requirements. For example, they allocate large amounts of memory at once and then use it in parts, or they allocate only objects of the same type during their execution. In earlier stages of C++, the common solution was to overload the operators new and delete. However, this technique is error prone and is subjected to various inefficiencies. Today, you can use an STL container instead of a custom memory manager. Consider the vector template: you can “allocate ” objects on it by calling the push_back() or insert() member functions. Likewise, you can “delete ” objects by calling the remove() and erase() member functions. Remember that all STL containers have an embedded allocator — a memory manager specifically optimized for that container. Therefore, an STL container usually provides better performance compared to a custom memory manager.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date