"The stack" is a per-thread address space range, dynamically reserved by a kernel when a thread is created. The reason why "stack" is often presented as preferable to "heap" is that, when using a thread's stack, the expensive part of allocation - address space reservation, and preparation of physical pages for backing the address space - has already been performed when the thread was created.
But kernels also provide mechanisms for doing your own address space reservation (mmap, VirtualAlloc), and there is nothing stopping you from using these to do bulk allocations up-front to create your own stacks. This can make common case allocations as cheap as "the stack", but the advantage is that you now control the semantics and lifetime of the stack you've created. Thus, it does not need to be coupled to - for example - the lifetime of a scope or function, as the thread stack is.
The "stack versus heap" dichotomy is an unfortunate mythology because it seems to, in practice, communicate the idea that when a thread stack is insufficient for some purpose (allocations must exceed scope boundaries, allocations may need to exceed thread stack limits, allocations require more fine-tuned reserve/commit behavior, and so on), then the only alternative is the heap, particularly for very granular allocations.
This is, again, a mythology, and it has confused the C++ world in particular for decades.
“A very common strategy I’ve seen in the programming world is thinking of certain desired high-level features, then directly codifying each one as a separate codepath. I call this strategy ‘top-down’ because it begins enforcing constraints on code by starting with high-level requirements. Such an approach would mean that, in the case of user interface rendering, each of the features I’ve mentioned—text, rectangles, rounded rectangles, rectangle borders, rounded rectangular borders, drop shadows, and icons—would all be implemented as distinct codepaths. Each feature is seen as a separate ‘case’ to handle, and the programmer in charge naïvely translates that into distinct cases in the code.
“This has a number of possible drawbacks. The first is simply that you may write (and thus maintain) more code to implement each feature, when compared to an alternative world where you got all of the features you wanted out of a smaller number of codepaths. That might not sound too bad for a small number of features, but it is worse than you might first assume. Each ‘case’ is heterogeneous, and so there is a degree of variability that propagates elsewhere, and forces itself not only into the implementation of each case, but also other code that must interact with each case. Any codepath that wants to programmatically parameterize this rendering codepath now must scale itself with the number of cases. For these reasons, I consider each addition of a ‘case’ as a multiplication of code, rather than an addition of code.”
free-list-based pools have an weird property people don't talk about - at some point the slot allocation pattern becomes almost random.
But there are alternative approaches, which don't use free lists at all. Lately I've been using a multi-level bit pool:
@usgraphics @neurospicy9 I definitely read it as the opposite which surprised me from your account. It read as ""manual"" programming going from a profession to a hobby
Muad'dib - the little mouse.
"I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path..."
The release date for the exploration puzzle platformer game "Öoo" is set for August 8th!
Please consider sharing and adding it to your Steam wishlist!
Steam👇
Hey! I'm a pixel artist with 7+ years of experience creating 2D game assets for games
What I can do for you: - Sprites & character design - Portraits & backgrounds - Tilesets & UI elements - Animation (walk cycles, attacks, VFX) - Cover art & promo materials
#pixelart#game
@zack_overflow For number 2, if you give each resizable array its own arena/reserved address space block, you have less relocation than a more standard/std approach.
Hello everyone!
I have not been on here for a long time since I’ve been busy working on the game Out of Sight which is releasing today! The game is our take on the concept of “second person perspective” with a mix of puzzles and horror. Check it out if it looks cool to you! 🧸
@Kinix17Games Thanks, I appreciate that.
The guy is a prolific reviewer. He has 17000 thousand reviews, all very similar to this one. If anything he's losing his touch a bit, some of the paragraphs are copy paste now it seems.