How much physical memory?

Hi,

Is there any way from kernel mode to determine how much physical memory is available, i.e., something similar to the Win32 function GlobalMemoryStatus().

I can only find MmQuerySystemSize() and that is useless. It “always” returns MmLargeSystem (if >= 32 MB memory).

Thanks,

Carsten Schmidt

What would you do with the info if you had it?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@email.dk
Sent: Saturday, September 19, 2009 4:04 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How much physical memory?

Hi,

Is there any way from kernel mode to determine how much physical memory is available, i.e., something similar to the Win32 function GlobalMemoryStatus().

I can only find MmQuerySystemSize() and that is useless. It “always” returns MmLargeSystem (if >= 32 MB memory).

Thanks,

Carsten Schmidt


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I once found it necessary under Vista to reduce non-paged pool usage if the
system did not have one memory block larger than 512MB in the physical
memory information. Our driver had an issue with low memory systems where
with shared memory for video and our network adapter the GUI could be frozen
if just enough memory was allocated during booting. Our memory blocks are
allocated with both virtual and physical addresses being required and we
never let them go until we are disabled or the system shuts down.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
What would you do with the info if you had it?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@email.dk
Sent: Saturday, September 19, 2009 4:04 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How much physical memory?

Hi,

Is there any way from kernel mode to determine how much physical memory is
available, i.e., something similar to the Win32 function
GlobalMemoryStatus().

I can only find MmQuerySystemSize() and that is useless. It “always” returns
MmLargeSystem (if >= 32 MB memory).

Thanks,

Carsten Schmidt


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hello,

the only way I know is to call the semi-documented
ZwQuerySystemInformation() with the semi-documented
SYSTEM_BASIC_INFORMATION class and multiply NumberOfPhysicalPages by
PageSize/PAGE_SIZE. It’s a pity that MmNumberOfPhysicalPages is not
directly exported.

  • Cay

On Sun, 20 Sep 2009 01:02:45 +0200, wrote:
> Hi,
>
> Is there any way from kernel mode to determine how much physical memory
> is available, i.e., something similar to the Win32 function
> GlobalMemoryStatus().
>
> I can only find MmQuerySystemSize() and that is useless. It “always”
> returns MmLargeSystem (if >= 32 MB memory).
>
> Thanks,
>
> Carsten Schmidt

I guess this can only be done with ZwQuerySystemInformation() and some constant i currently cant rememeber. Check www for more info,…

Regards

Kerem

Thanks,

ZwQuerySystemInformation() seems to be obsolete. Is there a safer way? More specifically, I want to create a section object for caching in a filter driver. I want to limit its size if there is only a little amount of physical memory available on the system.

Carsten

Alternatively, you can read SharedUserData->NumberOfPhysicalPages, but
this requires Windows XP or above and may be truncated.

  • Cay

On Sun, 20 Sep 2009 13:22:05 +0200, wrote:
> Thanks,
>
> ZwQuerySystemInformation() seems to be obsolete. Is there a safer way?
> More specifically, I want to create a section object for caching in a
> filter driver. I want to limit its size if there is only a little amount
> of physical memory available on the system.
>
> Carsten

How about:
L"\Registry\Machine\Hardware\ResourceMap\System Resources\Physical
Memory"
wrote in message news:xxxxx@ntdev…
>I guess this can only be done with ZwQuerySystemInformation() and some
>constant i currently cant rememeber. Check www for more info,…
>
>
> Regards
>
> Kerem
>

wrote in message news:xxxxx@ntdev…
> More specifically, I want to create a section object for caching in a
> filter driver. I want to limit its size if there is only a little amount
> of physical memory available on the system.
>

Then, maybe the memory state events will be useful for you:

\KernelObjects\HighMemoryCondition
\KernelObjects\LowMemoryCondition

They are signaled respectively when the memory goes low or becomes
available.
In Vista & Win7 other events exists, for more specific memory conditions.

–pa