r/cpp • • Oct 22 '26

These Bees Make the Wrong C++

https://dalerank.github.io/en/articles/wrong-cpp-bees.html
71 Upvotes

15 comments sorted by

View all comments

Show parent comment

4

u/protoloop Oct 22 '26

Thanks, those are great references!

For dynamic allocations you say you use arena allocators. What are the policies you use to determine which allocator to use and when?

For example in games (and I imagine in RTOS) we have immortal objects, per level objects, per frame objects, and per operation objects, each requiring a different arena. An operation (say a cooperative task that runs over multiple frames) needs to decide which arena to use for what. It might end up allocating all of those types of objects, so all the arenas need to be passed to the task. And if it uses the wrong one for something it might be hard to detect.

That's what I mean by extra complexity.

Most of the guidelines out there provide a bunch of do's and dont's, but i haven't found a good reference for idioms/best practices on how to satisfy them.

Does something like that exist? Or is it mostly experience and oral tradition?

4

u/remy_porter Oct 22 '26

I think teams will have their own documents about this, but yeah, a lot of it is experience. And it varies a lot by domain, too. Working on space robots was one set of constraints. I'm working on tomato picking robots right now, and uh... we're way more "whatevs" when it comes to memory allocations (probably to our detriment, though our performance is more bounded by "how fast can we make the arm move" than anything else).

1

u/protoloop Oct 22 '26

Yeah i get it. Similar in games - alot of BPs just aren't documented anywhere. Thanks for the info!