Link to home
Start Free TrialLog in
Avatar of kam_uk
kam_uk

asked on

Understanding server memory architecture :(

Hi

I am trying to understand server memory architecture and it's not going very well :(

I've read all the Wiki articles etc, but am still confused about a few things, so was hoping someone could explain them to me! Would be very grateful.

My environment is Windows - both 32 and 64bit OS's. (2003/2008).

My application is a 32bit app that has been succesfully running on Windows 2003 x32.

So, from what I understand:

1. Windows uses virtual address space (VAS). The OS manages the mapping of the VAS to the physical memory (http://en.wikipedia.org/wiki/Virtual_address_space). Now, each time an app runs on a OS, a new VAS is created, and each VAS is 4GB large.

2. If another app is opened, then another VAS (4GB) is created too.

3. What if the application has multiple processes? Is there one VAS per app, or one VAS per process?

4. Within each VAS, 2GB is reserved for the application and 2GB for the OS to help run the application. The app cannot reference that extra 2GB natively.

5. Are 32bit applications programmed to access only that initial 2GB of VAS per app (or process?) or are they developed to use more, but they are limited to that 2GB by the OS (which may cause slowness in the application if the initial 2GB is used up when neeeded)

6. The OS will map individual bytes of each VAS to physical memory based on the usage of the physical memory. If all the physical memory is used, then the application has to wait until some is free?

Hopefully, my understanding of the above is correct. But now we have the page file in the equation too :(

7. For #6, instead of waiting for the physical memory to become free, can the OS map bytes of the VAS to the page file (which is 1.5 x the value of the RAM)? So realistically, do we have 6GB RAM extra when 4GB DIMM's have been added?

8. Thus far, I have been of the understanding that a 32bit OS cannot understand more than 4GB RAM, so there is no point adding more than 4GB. But if it's using 6GB of the disk as extra RAM, why not just add that as actual RAM?

9. If I was going to create a x64 OS server, but only allocate it 4GB RAM, would that essentially be the same as an x32 OS server with 4GB RAM? it's only when we add more than 4GB that there are benefits of a x64 OS?

10. Or, instead of my claim in #9, there would actually be a benefit for a 32 bit app in running on a 4GB RAM 64bit server, since there is no limitation in the VAS for just 2GB to the application?

Hope someone can help!
ASKER CERTIFIED SOLUTION
Avatar of LMiller7
LMiller7
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kam_uk
kam_uk

ASKER

Thanks Lmiller7, I think I'm getting there, really appreciate you taking the time to answer.

Some follow up questions to round this off:

a) "9. If I was going to create a x64 OS server, but only allocate it 4GB RAM, would that essentially be the same as an x32 OS server with 4GB RAM? it's only when we add more than 4GB that there are benefits of a x64 OS?

 A 64 bit OS has other advantages besides access to more RAM. This includes a virtual address space of 8192 GB  for native apps, 4GB for compatible 32 bit apps"

You mention that a 64bit OS has 4GB for compatible 32bit apps. But - wouldn't these apps be coded to access the first 2GB only anyway, otherwise - as you say - there maybe access violations?

b) "6. The OS will map individual bytes of each VAS to physical memory based on the usage of the physical memory. If all the physical memory is used, then the application has to wait until some is free?

Mapping is done in blocks (4096 bytes in a 32 bit OS).  If there are no free blocks the system will page an active block out to make memory available. The system tries very hard to ensure this situation never happens. This paging is totally transparent to the application"

You say that the system will page out an active block to make memory available. Am I correct in thinking that when this happens, the OS basically checks for a block that has not been referenced in a while and 'stores' this on the hard disk temporarily whilst the physical/RAM memory block is used?

Hopefully I'm getting the hang of this :)
Applications that are Large Address Space Aware will recognize that addresses may be over 2GB and act accordingly.

Whan an application requests memory and there is insufficient free available the system will first look at the standby list. This is memory than is in use but can be reassigned without disk access. If it contains modified data it will have already been written to the pagefile. If it contained code there will already be a copy in the original files. In the event that the original application requires the memory that was reassigned it will have to be read from the pagefile or other files. This too is transparent to the application.

 You must remember that my explanations here are highly simplified. There are many details I have not mentioned, and many that aren't even publicly documented.

If you really want to understand this the best source is "Windows Internals", a Microsoft publication. This is not light reading. This is the most complete and accurate public documentation of Windows internal you will find anywhere.
Avatar of kam_uk

ASKER

Thanks very much. I will check out that publication too :)