very simple question
very simple question
am i right to assume that windows will never return a negative mem address??
like,
l = callocate( 1 )
could l ever < 0 ??
like,
l = callocate( 1 )
could l ever < 0 ??
-
- Posts: 775
- Joined: Jul 01, 2005 18:45
I was wondering about something. If a pointer is actually a hardware address, then what happens when you exceed the range of 4 bytes? If you take (2^32)/1024^3=4 GB of memory. So what happens when i install more gb? I have a suspiscion that there is some knowledge concerning pointers that I lack, so if that is true, enlighten me. If not, what happens?
-
- Posts: 775
- Joined: Jul 01, 2005 18:45
4gb of memory is a limit imposed by 32-bit processors (95% of desktops today). 64-bit CPUs like the Itanium and AMD64 use 64-bit addressing, which is really the main draw of those processors.
However, the number inside pointers doesn't actually specify the physical byte in memory you're accessing. "Protected Mode" CPUs (e.g. every CPU since the 386) allows for the OS to dish out "virtual memory" to each program. This prevents you from, say, writing to &ha000 and messing up the screen. So you could allocate up to 4gb (or to whenever Windows says "no more") inside program, and Windows would dump whatever memory can't fit in RAM on your hard drive (at the price of a very expensive speed cut).
However, the number inside pointers doesn't actually specify the physical byte in memory you're accessing. "Protected Mode" CPUs (e.g. every CPU since the 386) allows for the OS to dish out "virtual memory" to each program. This prevents you from, say, writing to &ha000 and messing up the screen. So you could allocate up to 4gb (or to whenever Windows says "no more") inside program, and Windows would dump whatever memory can't fit in RAM on your hard drive (at the price of a very expensive speed cut).
-
- Posts: 775
- Joined: Jul 01, 2005 18:45
It looks like windows does support huge blocks of memory, but you have to be running a server to do it:
http://msdn.microsoft.com/library/defau ... ension.asp
http://msdn.microsoft.com/library/defau ... ension.asp
32-bit processors from pIII up are able to use something like 36 TB or like that of memory, when you enable special segmented mode. It's kinda like 16 bit real mode, instead it's 32 bit segmented pmode ;). But there are segments & offsets so all that segment offset stuff returns. However I guess only some special scientific machines or what are set up that way.
Pointers you use in Windows point to "logical" memory, there is circuitry in CPU which translates these adresses into real physical ones. Even when your windows memory looks like you have 32 meg linear chunk, in reality it might be scattered all over your mem or HDD.
Pointers you use in Windows point to "logical" memory, there is circuitry in CPU which translates these adresses into real physical ones. Even when your windows memory looks like you have 32 meg linear chunk, in reality it might be scattered all over your mem or HDD.