Solved

Understanding server memory architecture :(

Posted on 2010-08-31
4
416 Views
Last Modified: 2013-12-01
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!
0
Comment
Question by:kam_uk
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
LMiller7 earned 500 total points
ID: 33570876
1. Yes
2. Yes
3. The OS doesn't know about applications, only processes.
4. Yes
5. Applications are programmed to access only the first 2GB because access beyond this point would cause an access violation and termination of the process.
6. 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.
7. The system does not and cannot use the pagefile the same way as it uses RAM. The pagefile, and executable files, DLL's etc., are used to hold data and code when it is not in RAM. The total of code and data in use can be several times the size of RAM and still have good performance.
8. As mentioned the system does not use the pagefile the same as RAM. It is also orders of magnitude slower. This isn't normally a serious problem becasue it is used only for rarely used data.
9. 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. Whether these advantages will be worthwhile in a specific setting is another matter.
10. Answered above.
0
 
LVL 3

Author Comment

by:kam_uk
ID: 33571021
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 :)
0
 
LVL 10

Expert Comment

by:LMiller7
ID: 33571891
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.
0
 
LVL 3

Author Comment

by:kam_uk
ID: 33580532
Thanks very much. I will check out that publication too :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we have discussed the manual scenarios to recover data from Windows 10 through some backup and recovery tools which are offered by it.
Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now