Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Heap / Stack Access Speed

Name: Anonymous 2010-01-14 2:10

Quick question. Using C, is memory or the program's stack faster to access then the memory that's allocated on the heap?

Name: Anonymous 2010-01-14 2:14

stack is much hotter, but be careful with that bitch. she may be a bit bulkier but the heap is always there for you when you need her

Name: Anonymous 2010-01-14 2:16

Unless you're using some strange processor architecture, no.

Name: Anonymous 2010-01-14 2:34

>>3
Incorrect, but the difference is very, very tiny. When using heap memory, it's possible that the page could be inside the page/swap file. Most people wouldn't need to worry about that thought.

Name: Anonymous 2010-01-14 2:43

Is it not also such that stack variables can be accessed with an 8-bit displacement, while heap variables will require the full 32-bit displacement?

Name: Anonymous 2010-01-14 5:15

>>1,5
I'm sure the size of your mov instruction is the bottleneck in your program.

Name: Anonymous 2010-01-14 6:02

>>6
It is. That is why I'm using a ENTERPRISE-GRADE object-oriented mov replacement

Name: Anonymous 2010-01-14 7:41

>>7
So you decided to fix the bottleneck by replacing one instruction with one that is an order of magnitude more bloated? You should be a consultant.

Name: Anonymous 2010-01-14 8:56

Using C
No. C has nothing to do with it.

Name: Anonymous 2010-01-14 9:57

>>1
faster to access then
faster then
Excuse my brutal honesty, but your grammar is not unlike that of an idiot.
When comparing, you should use ``than''. ``Then'' is used after ``if'' or in similar situations.

Name: Anonymous 2010-01-14 10:48

>>10
yhbt

Name: Anonymous 2010-01-14 11:26

>>4
The stack can be swapped out too, so your point is moot.

Name: Anonymous 2010-01-14 11:47

>>4
The stack for a program is also likely in the processor's cache, so it is even more imperceptibly faster.

Name: sage 2010-01-14 14:19

SEX MY SEX

Name: Anonymous 2010-01-14 16:59

>>14
SEX MY ANUS

Name: Anonymous 2010-01-14 17:24

>>15
Anus My Anus

Name: Anonymous 2010-01-15 1:01

>>13
This pretty much answers OP's question. The top of the stack is virtually always in the processor cache, whereas heap is hit or miss (literally) depending on the order of your allocations, how fragmented your memory is, how much memory you have overall, etc.

But the real answer to your question, >>1, is that if you're asking such a high-level question without understanding how processor caches work, then you should not be worrying about it.

Name: Anonymous 2011-02-03 5:20


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List