On 12/1/14 3:22 PM, Suliman wrote:
Could anybody explain why there is opinion that stack is fast and the
heap is slow. All of them are located in the same memory. So the access
time should be equal.

Measure it :)

But short answer is twofold:

1. stack is usually hot in the local processor cache, so it's almost always the fastest to access. 2. The *access* to the heap memory isn't necessarily slower, as the heap memory can just as easily be in the cache, it's *allocating* heap memory that is slower (and vastly so) than allocating stack memory.

-Steve

Reply via email to