-1

I have 3 types of allocators, but I can't understand when to use custom allocators :

Linear Allocator
Stack Allocator
Pool Allocator

How that allocators work?

0x123
  • 99
  • 1
  • 3
    These are *your* allocators. How should we know what do they do? – Yksisarvinen May 21 '19 at 12:52
  • Where did you get the allocators from? If you made them yourself, how can you not know how they work? Did you just copy them from somewhere? Then please don't fall into the [cargo cult programming](https://en.wikipedia.org/wiki/Cargo_cult_programming) trap. And *when* to use custom allocators, that is way to broad and depends on your requirements and use-cases. – Some programmer dude May 21 '19 at 13:18
  • related: https://stackoverflow.com/questions/826569/compelling-examples-of-custom-c-allocators – kmdreko May 26 '19 at 03:53

1 Answers1

2

You use custom allocators when you have evidence that C++'s default allocators are insufficient for the task at hand. One of the more common places you'll see this is in game development, where maintaining a highly organized, compacted memory footprint helps with performance. The allocators you mention are all ways of shaping these allocations, generally with a view towards reducing fragmentation, improving locality of reference, working set issues, and the like.

Edit: I need 23 more rep to comment. I will refactor this as a comment when I have achieved this milestone, since it's not really an answer, and your question is a bit too broad as is.