Resource pool for data structure

When implementing elementary data structure, such as stack, queues, linked listet al. Should I create a pool of resources (nodes) by dynamically allocating memory in a bundle or should I allocate memory separately each time I need a node?

+3
source share
2 answers

It totally depends on your goals. By default (i.e. unless you really need to do otherwise), just do a normal distribution for each next node.

Memory pools compared to just distribution nodes:

  • Make selection faster. Depending on the underlying distribution mechanism, sometimes much faster.

  • , .

  • : , . , (, 1000 ), .

- .

++ allocator.

+2

. , :

, , , O (1). " " , , , , , O (n). , .

node, , , , , . , , .

, , , , , .

+1

Source: https://habr.com/ru/post/1755092/


All Articles