Which is faster: Stack allocation or Heap allocation

前端 未结 23 2138
悲&欢浪女
悲&欢浪女 2020-11-22 07:40

This question may sound fairly elementary, but this is a debate I had with another developer I work with.

I was taking care to stack allocate things where I could, i

23条回答
  •  独厮守ぢ
    2020-11-22 07:46

    You can write a special heap allocator for specific sizes of objects that is very performant. However, the general heap allocator is not particularly performant.

    Also I agree with Torbjörn Gyllebring about the expected lifetime of objects. Good point!

提交回复
热议问题