Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GlobalMemoryStatusEx

6 views
Skip to first unread message

George M. Garner Jr.

unread,
Aug 18, 2004, 1:18:19 PM8/18/04
to
GlobalMemoryStatusEx returns the "total physical memory" in the ullTotalPhys
member of the MEMORYSTATUSEX structure.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/globalmemorystatusex.asp.
But the value returned by GlobalMemoryStatusEx is always somewhat less than
the addressable total physical memory on a system. Thus, on the current
system GlobalMemoryStatusEx returns 3FF7D000 in the ullTotalPhys member of
the MEMORYSTATUSEX structure. On the other hand:

lkd> db /p 3ffef000
3ffef000 77 83 6a 61 f7 45 83 d8-8e 39 67 9f 3e 54 66 58 w.ja.E...9g.>TfX
3ffef010 f6 71 b6 6a 59 87 4e 19-52 29 92 41 ac 9f 8e 23 .q.jY.N.R).A...#
3ffef020 57 0f 83 43 b0 b0 ee 4a-5b a3 1d 5e 44 d7 b8 63 W..C...J[..^D..c
3ffef030 76 82 de 7b 63 aa 6d 61-a8 a2 15 8e 6b ec 02 57 v..{c.ma....k..W
3ffef040 ae 03 43 b0 67 5a 8e 59-02 49 5c e5 87 29 37 74 ..C.gZ.Y.I\..)7t
3ffef050 a2 5e ab 63 aa 6d 61 88-12 15 ae 7f 6a 91 b7 ae .^.c.ma.....j...
3ffef060 03 43 b0 b0 ee 4a 5b 32-0d 4e 25 d6 4c 45 45 53 .C...J[2.N%.LEES
3ffef070 6f da 63 aa 6d 41 e8 f2-15 8e bb 5c d3 d7 ce 77 o.c.mA.....\...w

Clearly there is memory that is addressable beyond 3FF7D000.

Would someone please comment on what the value returned in ullTotalPhys
member of the MEMORYSTATUSEX structure represents. Is this the total
physical memory that is *available* to the kernel? Is there a more accurate
way to determine the total physical memory?

Thanks,

George.


Arkady Frenkel

unread,
Aug 18, 2004, 6:07:19 PM8/18/04
to
Such question arise from time to time , look at
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=OhNJ7%23X5DHA.104
0%40TK2MSFTNGP10.phx.gbl&rnum=4&prev=/groups%3Fq%3DGlobalMemoryStatusEx%2520
TotalPhys%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
(aware of wrap )
Arkady

"George M. Garner Jr." <gmga...@erols.com> wrote in message
news:u4ScddUh...@TK2MSFTNGP09.phx.gbl...

George M. Garner Jr.

unread,
Aug 18, 2004, 6:15:10 PM8/18/04
to
Arkady,

Thanks for the reference to this URL (which is almost as long as the thread
that it references). :-)
The gist of this thread seems to be that ullTotalPhys represents the total
memory available to the kernel and does not include physical memory reserved
for certain devices, such as video cards. Perhaps there should be some
changes to the documentation to reflect this.

Thanks,

George.


George M. Garner Jr.

unread,
Aug 18, 2004, 11:15:07 PM8/18/04
to
Arkady,

After a little more research I have determined that this is the result of a
bug in GlobalMemoryStatusEx which determines the total physical memory using
an algorithm that fails to account for the presense of large pages. In
effect, GlobalMemoryStatusEx *calculates* the amount of physical memory by
multiplying the total number of physical pages by the default page size.
The problem is that the physical pages are not all the same size and by
erroneously assuming that they are GlobalMemoryStatusEx underestimates the
amount of physical memory present on a system. Since ullAvailPhys is
calculated in the same way it presumably is similarly erroneous, but that is
harder to verify.

NtQuerySystemInformation with an information class of SystemBasicInformation
provides the HighestPhysicalPage. The following formula yields the correct
result:

(HighestPhysicalPage + 1) x PhysicalPageSize

Regards,

George.


Arkady Frenkel

unread,
Aug 19, 2004, 2:27:59 AM8/19/04
to
Good work , George , thanks
Arkady

"George M. Garner Jr." <gmga...@erols.com> wrote in message

news:%23Q4u9qZ...@tk2msftngp13.phx.gbl...

0 new messages