Public Group

the stack

This topic is 4552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

i find this a little wierd: lets say i create a pointer then assign to an address ,then i try to read the address it's always an eight digit hexadecmial value. with some math max value = 16^8 = (2x2x2x2)^8 = (2^4)^8 = 2^(4x8) = 2^32 , which implies that the size of the pointer is 32bits. my question is: can the stack only hold 2^32 addresses?

Share on other sites
I don't know, but I don't think you need more than 4,294,967,296 addresses :)

Share on other sites
Yes, in 32-bit hardware the size of pointers is usually 32 bit and they can address up to 4GB in virtual address space. Why is this weird? And what the stack has to do with it?

Share on other sites
Get Windows/Linux x64 and the pointer should be 64bits (I think).

Share on other sites
That's what makes it a 32-bit architecture; the computer works best with 32-bit values.

Share on other sites
Two questsions,

Does this mean that each program has a maximum of ~4gb memeory, or all programs running?

This would also include variables both on the stack, and on the heap, correct?

Share on other sites
Quote:
 Original post by EzbezTwo questsions,Does this mean that each program has a maximum of ~4gb memeory, or all programs running?

It means that with a 32 bit pointer your application can address 232 differet memory addresses. It doesn not necesssarily mean that you can use that much memory. How much you can use depends on how much the operating system allows you to use.

Quote:
 Original post by EzbezThis would also include variables both on the stack, and on the heap, correct?

It addresses the memory. Stack, heap, free store, whatever, are all parts of the same memory.

Thanks!

Share on other sites
Quote:
 Does this mean that each program has a maximum of ~4gb memeory, or all programs running?

It means each program has a ~4gb address space. However you can't necessarily access all of that address space, nor does it mean the maximum amount of memory you can use is 4gb (you could for example have the 1st gb of address space refer to one part of memory and then alter it so that it refers to another part of memory). How this all works and what parts of the address space you can access depend upon the OS. Reading this article on virtual memory should give you more info on how a modern OS manages all this.

1. 1
2. 2
3. 3
Rutin
18
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633659
• Total Posts
3013217
×