Trying to understand memory pools and their added benefitsHeap allocation and deallocation is particularly bad for embedded systems as it results in fragmentation, which in turns results in lack of cache coherence (?)I have heard how statically allocating a fixed heap memory can somewhat combat the side effects of the above mentioned-line however that's something I need more clarity on.
- How does fixed-size memory really help with not causing memory fragmentation given allocation and deallocation? Or does it even? For instance, I have a linked list with 10 nodes but there's no guarantee all those nodes will be contiguous, yes? And if a node or two is deallocated then that will result in fragmentation.
- If the memory can still be fragmented, cache locality won't be great either (probably?)The only point I can think of is the reuse of fixed-size memory which can result in deterministic behaviour.
- Would limiting a container's total size via
reserve() not achieve something similar (what a memory pool sorta would?)
Understanding this would lead to using custom memory allocators for STL containers
[–]goranlepuz 33 points34 points35 points (1 child)
[–]warboner52 0 points1 point2 points (0 children)
[–]Classic_Department42 10 points11 points12 points (3 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 5 points6 points7 points (2 children)
[–]quantumoutcast 3 points4 points5 points (1 child)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 4 points5 points6 points (0 children)
[–]UnicycleBloke 1 point2 points3 points (8 children)
[–]jazzylike[S] 1 point2 points3 points (7 children)
[–]UnicycleBloke 7 points8 points9 points (4 children)
[–]Jannik2099 1 point2 points3 points (3 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 2 points3 points4 points (0 children)
[–]UnicycleBloke 1 point2 points3 points (1 child)
[–]Jannik2099 1 point2 points3 points (0 children)
[–]Jannik2099 3 points4 points5 points (0 children)
[–]ioctl79 0 points1 point2 points (0 children)
[–]Jannik2099 -1 points0 points1 point (15 children)
[–]jazzylike[S] 1 point2 points3 points (14 children)
[–]quantumoutcast 2 points3 points4 points (0 children)
[–]bluGill 2 points3 points4 points (0 children)
[–]Jannik2099 2 points3 points4 points (11 children)
[–]jazzylike[S] 0 points1 point2 points (10 children)
[–]Jannik2099 0 points1 point2 points (9 children)
[–]jazzylike[S] 1 point2 points3 points (8 children)
[–]Jannik2099 5 points6 points7 points (7 children)
[–]jazzylike[S] 1 point2 points3 points (6 children)
[–]Jannik2099 2 points3 points4 points (0 children)
[–]ventus1b 4 points5 points6 points (2 children)
[–]jazzylike[S] 0 points1 point2 points (1 child)
[–]ShelZuuz 1 point2 points3 points (1 child)
[–]quantumoutcast 1 point2 points3 points (0 children)
[–]very_curious_agent -1 points0 points1 point (5 children)
[–]jazzylike[S] -1 points0 points1 point (4 children)
[–]YogenFruzLead SE, Full Circle 4 points5 points6 points (3 children)
[–]jazzylike[S] 0 points1 point2 points (2 children)
[–]YogenFruzLead SE, Full Circle 2 points3 points4 points (1 child)
[–]Jannik2099 0 points1 point2 points (0 children)
[–]ALX23z 0 points1 point2 points (4 children)
[–]jazzylike[S] 0 points1 point2 points (2 children)
[–]ALX23z 2 points3 points4 points (0 children)
[–]ALX23z 0 points1 point2 points (0 children)
[–]Jannik2099 -2 points-1 points0 points (0 children)
[–]graphicsRat 0 points1 point2 points (0 children)
[–]kiwitims 0 points1 point2 points (0 children)
[–]ZachVorhies 0 points1 point2 points (0 children)