Custom Allocator Tutorial - How-To

Описание к видео Custom Allocator Tutorial - How-To

Allocators are objects responsible for encapsulating memory management. They are used all around the Standard Library, particularly STL. By default, the standard classes, like containers, smart pointers, etc., use a default allocator, which is simply a std::allocator. The purpose of such entity is to abstract away all the details about low-level memory operations, but also provide some meta information about the type they are responsible of managing. The default allocator simply uses the operators new and delete to obtain and release memory, so it’s a simple wrapper around standard C++ memory operations. So, why would someone want to make their own? Let’s assume we want to track how much memory our containers used for statistical reasons. Ok, let’s build a tracking allocator.

Source code: https://pastebin.com/XiwGBmu4

Комментарии

Информация по комментариям в разработке