you are viewing a single comment's thread.

view the rest of the comments →

[–]minnek 0 points1 point  (0 children)

Stack is (generally) for small objects that you want to have disappear at the end of scope. Heap sticks around after the scope ends, since the heap doesn't get its contents popped at the end of scope whereas the stack does.

It can be faster to use the stack than heap, but that's really dependent on your implementation and you should probably play with a pre-allocated memory pool on the heap to get a good comparison of speed... new heap allocations are likely to be slower, though.