Originally Posted by
abachler
the OS uses the global descriptor table and the local descriptor tables to manage physical and virtual memory. Applications do not have access to those structures as they are only available in ring 0. The OS doesn't know how much of your specific program is in memory or not as such, it just knows globally which memory locations are in physical memory and which are on disk, It would have to specifically do a page walk to collect that information, which would be of no use to it, so its not something the kernel would do, but it is something only the kernel can do.
There is no reason you would need to know this information. The kernel handles paging transparently. Whatever it reports as free system wide physical memory is what is available to your process as physical memory. Each process has access to all available physical memory up to its per process limit, which is 2GB normally or 3GB if you use the /3gb switch. However, just because it reports, e.g. 2GB free physical memory, doesn't mean if you allocate a 2GB object that the entire object will be in physical ram, the OS will handle what is and is not paged to optimize system wide performance. I believe there is a way of marking heap memory as being non-paged though, check out the heap functions.