menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Custom All...
source image

Medium

1w

read

29

img
dot

Image Credit: Medium

Custom Allocators, Memory Pools, And std::unordered_map

  • Taking a heaptrack memory profile of the default allocator revealed 2,000,000 heap allocations when adding, deleting, and re-adding 1,000,000 entries to an std::unordered_map.
  • To avoid heap allocations in the application's hot path, the solution proposed involves using a memory pool in conjunction with a custom allocator.
  • The custom allocator's implementation includes functions allocate() and deallocate(), complying with std::allocator_traits for proper interfacing with the standard library.
  • By implementing the custom allocator and utilizing a memory pool, transitioning from heap to stack memory allocation was successful, as observed in the heaptrack memory profile.

Read Full Article

like

1 Like

For uninterrupted reading, download the app