3 ms·
I just do my darndest never ever use the heap. Let the stack be your memory manager. I think if you come from other languages you assume the heap is the defaul
by softwaredoug 3y ago
I just do my darndest never ever use the heap. Let the stack be your memory manager.
I think if you come from other languages you assume the heap is the default when it should be the exception.
- pstrateman 3y agowhich works great until you need more than 8MiB of memory. stack is usually quite limited unless you very much control the environment
- maattdd 3y agoHow do you create recursive data structure on the stack?
- rightbyte 3y agoUsing pointers to the stack?
- maattdd 3y agoPointers to stack sound like a recipe for disaster (all those pointers will be dangling very very soon).
- softwaredoug 3y agoI’d argue it’s safer to have the paradigm of “i own stuff then delegate it you” (ie down the stack) then the non hierarchy chaos the heap invites
- galangalalgol 3y agoIs the normal stack size for a thread still 8MB? Most of my c++ has always been simulation or signal processing where a buffer of objects to be simulated or samples/pixels to be processed always exceed sane stack sizes. The standard answer is to preallocate these buffers and reuse them. Smart pointers are pretty useful in the simulation case, but not really necessary for the signal processing.