|
|
|
|
|
by headPoet
1109 days ago
|
|
"anything stored in that pointer to memory you got back from malloc() is stored in an area of ram called "the heap", which is moderately slower to access than it is to access the stack."
Is this true, or a myth? Ignoring the allocation cost and access patterns making cache misses more likely, surely memory is just memory |
|
In contrast, what’s where on the stack can often be (and often must be) known statically by the compiler and accessed directly, even moved entirely out of memory and into a register. (It’s possible to do this with suitably constrained dynamic allocations, but the optimization is much harder.)