r/cpp • u/Little-Reflection986 • Feb 16 '26
Favorite optimizations ??
I'd love to hear stories about people's best feats of optimization, or something small you are able to use often!
135
Upvotes
View all comments
Show parent comment
10
u/theICEBear_dk Feb 16 '26
That makes sense. Thanks for the good points. I was worried about the general overhead of deallocation which can count even when you are using something garbage collected like Java or C#. I have gotten large gains in the past by just reducing the amount of temporary allocations on the heap there. we have stack in c++ so it matters less most of the time.
Unless you do like one of my interns and try to make a std::array of about 64MB size on the stack (he had not really thought about the fact that his 1000+ objects had an internal size that quickly added up he just saw the 1000). The OS was not happy about that.