System physical memory

Anyone knows how can i determine my system’s physical memory in order to
calculate the amount of data to allocate in a common buffer?

Well, in user mode, GlobalMemoryStatusEx, and in kernel mode,
ZwQuerySystemInformation (undocumented but see nebbet book), seem to be
possibilities. There might be a better option?

“Nikolas Stylianides” wrote in message news:xxxxx@ntdev…
> Anyone knows how can i determine my system’s physical memory in order to
> calculate the amount of data to allocate in a common buffer?
>
>

Take a look at the registry entry:

“\REGISTRY\MACHINE\HARDWARE\RESOURCEMAP\System Resources\Physical Memory”

This will give you the actual physical memory. But remember that /MAXMEM
and /BURNMEMORY will impact the memory available to the system.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Nikolas Stylianides” wrote in message news:xxxxx@ntdev…
> Anyone knows how can i determine my system’s physical memory in order to
> calculate the amount of data to allocate in a common buffer?
>
>

Don Burn wrote:

Take a look at the registry entry:

“\REGISTRY\MACHINE\HARDWARE\RESOURCEMAP\System Resources\Physical Memory”

This will give you the actual physical memory. But remember that /MAXMEM
and /BURNMEMORY will impact the memory available to the system.

I have already reached that part when i applied a search for physical
memory in the regedit.exe
The values that the key contains is just one: “.Translated”. How this
values are translated in Human readable format?
Any links i can follow and learn?

This is a resource list, contained in KEY_VALUE_PARTIAL_INFORMATION the data
field is of type CM_RESOURCE_LIST.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Nikolas Stylianides” wrote in message news:xxxxx@ntdev…
> Don Burn wrote:
>
>>Take a look at the registry entry:
>>
>>“\REGISTRY\MACHINE\HARDWARE\RESOURCEMAP\System Resources\Physical Memory”
>>
>>This will give you the actual physical memory. But remember that /MAXMEM
>>and /BURNMEMORY will impact the memory available to the system.
>>
>>
>>
> I have already reached that part when i applied a search for physical
> memory in the regedit.exe
> The values that the key contains is just one: “.Translated”. How this
> values are translated in Human readable format?
> Any links i can follow and learn?
>
>

There was a routine like MmQuerySystemSize or such - it returned the enum
values like Small, Large and Huge and was intended exactly for such hinting.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Nikolas Stylianides”
To: “Windows System Software Devs Interest List”
Sent: Friday, July 22, 2005 2:17 PM
Subject: [ntdev] System physical memory

> Anyone knows how can i determine my system’s physical memory in order to
> calculate the amount of data to allocate in a common buffer?
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Don Burn wrote:

This is a resource list, contained in KEY_VALUE_PARTIAL_INFORMATION the data
field is of type CM_RESOURCE_LIST.

Thank you very much. I think i will follow Don Burn’s advice because i
want to know exactly the amount of physical memory.

Nikolas Stylianides wrote:

Don Burn wrote:

> This is a resource list, contained in KEY_VALUE_PARTIAL_INFORMATION
> the data field is of type CM_RESOURCE_LIST.
>
>
>
>
Thank you very much. I think i will follow Don Burn’s advice because i
want to know exactly the amount of physical memory.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@4plus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I have copied the contents of the “.Translated” value in a buffer and
assigned the buffer at a PCM_RESOURCE_LIST. The contents bytes are 84
bytes. The type i get when i use the
CM_PARTIAL_RESOURCE_DESCRIPTOR type field is not of type memory. I can
not shift on that buffer because is not a valid memory block.

Any tips?

Nikolas Stylianides wrote:

Nikolas Stylianides wrote:

> Don Burn wrote:
>
>> This is a resource list, contained in KEY_VALUE_PARTIAL_INFORMATION
>> the data field is of type CM_RESOURCE_LIST.
>>
>>
>>
>>
> Thank you very much. I think i will follow Don Burn’s advice because
> i want to know exactly the amount of physical memory.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@4plus.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
I have copied the contents of the “.Translated” value in a buffer and
assigned the buffer at a PCM_RESOURCE_LIST. The contents bytes are 84
bytes. The type i get when i use the
CM_PARTIAL_RESOURCE_DESCRIPTOR type field is not of type memory. I can
not shift on that buffer because is not a valid memory block.

Any tips?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@4plus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

OK i get it.

  1. Read the last 8 bytes of the list in a 64-bit variable (liLastPos).
  2. liSize = liLastPos + 0x10000 (The memory is in meseured in 64KB chunks.)
  3. Size In MB = liSize / 1024 /1024

Is it correct?

Nikolas Stylianides wrote:
> Anyone knows how can i determine my system’s physical memory in order to
> calculate the amount of data to allocate in a common buffer?

One important question that has yet to be asked: Why do you think you
need to know the amount of system memory present? Generally, you should
allocate the minimum buffers you need for your device to work well.

If you’re planning to allocate some “percentage” of the available
physical memory, this fails the “what if everyone did this?” test.

In other words: imagine if all (or a lot, or even just several) drivers
worked this way. Then, imagine if the total sum of the percentages of
memory all of these drivers decide to allocate ends up being more than
100%. If that ever happened, then no matter how much memory the user
added to their machine, they would never be able to boot because they
would always end up not having enough.

…/ray..

Ray Trent wrote:

Nikolas Stylianides wrote:
> Anyone knows how can i determine my system’s physical memory in
order to
> calculate the amount of data to allocate in a common buffer?

One important question that has yet to be asked: Why do you think you
need to know the amount of system memory present? Generally, you
should allocate the minimum buffers you need for your device to work
well.

If you’re planning to allocate some “percentage” of the available
physical memory, this fails the “what if everyone did this?” test.

In other words: imagine if all (or a lot, or even just several)
drivers worked this way. Then, imagine if the total sum of the
percentages of memory all of these drivers decide to allocate ends up
being more than 100%. If that ever happened, then no matter how much
memory the user added to their machine, they would never be able to
boot because they would always end up not having enough.

I agree with you Ray. This is a driver for a customize device in a
system that the only memory consuming device is me. That is why i am
planning to allocate a prercentage based upper limit memory. Suppose i
choose by default to allocate 120 MByte of common buffer for a card that
resides in a system of 256MB. I need the total memory to estimate the
upper limit of my memory and not the absolute size of the common buffer.

I also believe that a kernel should provide functions for quering the
memory state. This “Find out your self” technique is unpolite both for
us and the system. And you know what they say. If you want to respect
you, first you must respect your self.

I agree. It is silly that there is no standard ddi for getting the memory
size. Of course there are issues here as hot-add of memory is supported in
some version or other of the OS, so like asking how many cpus are there, the
answer depends on when you ask the question.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
Nikolas Stylianides
Sent: Wednesday, July 27, 2005 4:22 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] System physical memory

Ray Trent wrote:

> Nikolas Stylianides wrote:
> > Anyone knows how can i determine my system’s physical memory in
> order to
> > calculate the amount of data to allocate in a common buffer?
>
> One important question that has yet to be asked: Why do you
think you
> need to know the amount of system memory present? Generally, you
> should allocate the minimum buffers you need for your
device to work
> well.
>
> If you’re planning to allocate some “percentage” of the available
> physical memory, this fails the “what if everyone did this?” test.
>
> In other words: imagine if all (or a lot, or even just several)
> drivers worked this way. Then, imagine if the total sum of the
> percentages of memory all of these drivers decide to
allocate ends up
> being more than 100%. If that ever happened, then no matter
how much
> memory the user added to their machine, they would never be able to
> boot because they would always end up not having enough.

I agree with you Ray. This is a driver for a customize device
in a system that the only memory consuming device is me. That
is why i am planning to allocate a prercentage based upper
limit memory. Suppose i choose by default to allocate 120
MByte of common buffer for a card that resides in a system of
256MB. I need the total memory to estimate the upper limit of
my memory and not the absolute size of the common buffer.

I also believe that a kernel should provide functions for
quering the memory state. This “Find out your self” technique
is unpolite both for us and the system. And you know what
they say. If you want to respect you, first you must respect
your self.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
xxxxx@lists.osr.com

Mark Roddy wrote:

I agree. It is silly that there is no standard ddi for getting the memory
size. Of course there are issues here as hot-add of memory is supported in
some version or other of the OS, so like asking how many cpus are there, the
answer depends on when you ask the question.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

>-----Original Message-----
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of
>Nikolas Stylianides
>Sent: Wednesday, July 27, 2005 4:22 AM
>To: Windows System Software Devs Interest List
>Subject: Re: [ntdev] System physical memory
>
>Ray Trent wrote:
>
>
>
>>Nikolas Stylianides wrote:
>>
>>
>>>Anyone knows how can i determine my system’s physical memory in
>>>
>>>
>>order to
>>
>>
>>>calculate the amount of data to allocate in a common buffer?
>>>
>>>
>>One important question that has yet to be asked: Why do you
>>
>>
>think you
>
>
>>need to know the amount of system memory present? Generally, you
>>should allocate the minimum buffers you need for your
>>
>>
>device to work
>
>
>>well.
>>
>>If you’re planning to allocate some “percentage” of the available
>>physical memory, this fails the “what if everyone did this?” test.
>>
>>In other words: imagine if all (or a lot, or even just several)
>>drivers worked this way. Then, imagine if the total sum of the
>>percentages of memory all of these drivers decide to
>>
>>
>allocate ends up
>
>
>>being more than 100%. If that ever happened, then no matter
>>
>>
>how much
>
>
>>memory the user added to their machine, they would never be able to
>>boot because they would always end up not having enough.
>>
>>
>I agree with you Ray. This is a driver for a customize device
>in a system that the only memory consuming device is me. That
>is why i am planning to allocate a prercentage based upper
>limit memory. Suppose i choose by default to allocate 120
>MByte of common buffer for a card that resides in a system of
>256MB. I need the total memory to estimate the upper limit of
>my memory and not the absolute size of the common buffer.
>
>I also believe that a kernel should provide functions for
>quering the memory state. This “Find out your self” technique
>is unpolite both for us and the system. And you know what
>they say. If you want to respect you, first you must respect
>your self.
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as:
>xxxxx@hollistech.com To unsubscribe send a blank email to
>xxxxx@lists.osr.com
>
>
>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@4plus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Yes but in WDM hotswap is supported. If one considers memory to be a
device being handle by Memory manager then why not to sypply a callback
function
in order every time a hot-add or remove memory action is taken to be
informed and take actions as well?

A better way to do this is to use WMI. Try the Win32_PhysicalMemory class in the root\cimv2 hive. It has pretty much everything you are asking for.

Don Burn wrote:This is a resource list, contained in KEY_VALUE_PARTIAL_INFORMATION the data
field is of type CM_RESOURCE_LIST.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Nikolas Stylianides” wrote in message news:xxxxx@ntdev…
> Don Burn wrote:
>
>>Take a look at the registry entry:
>>
>>“\REGISTRY\MACHINE\HARDWARE\RESOURCEMAP\System Resources\Physical Memory”
>>
>>This will give you the actual physical memory. But remember that /MAXMEM
>>and /BURNMEMORY will impact the memory available to the system.
>>
>>
>>
> I have already reached that part when i applied a search for physical
> memory in the regedit.exe
> The values that the key contains is just one: “.Translated”. How this
> values are translated in Human readable format?
> Any links i can follow and learn?
>
>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Start your day with Yahoo! - make it your home page