Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Find actual total physical memory

- - - - -

  • Please log in to reply
12 replies to this topic

#1
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,902 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

I'm writing a new program that needs to read how much RAM is on a PC, and then create a disk partition that matches that size. The problem I am encountering is that I cannot find exactly the correct class in WMI that has this information. Using my own PC as an example, I have 2 different memory amounts.

1 - 4.00 GB is reported as "Installed memory" on Computer Properties
2 - 2.43 GB usable in the same place, also matches Task Manager's Performance tab of 2492 Total Physical Memory.

I want to get this 4GB value that I see in Computer Properties, but all I can find is the lower number. Examples:

Win32_ComputerSystem: TotalPhysicalMemory = 2613805056
Win32_OperatingSystem: TotalVisibleMemorySize = 2552544
Win32_PhysicalMemory: Capacity = 2147483648
Win32_PhysicalMemory: Round(Capacity / (1024^2)) = 2048

The only thing close I can find is Win32_MemoryArray (or MemoryDevice): EndingAddress = 4194303.
That is presuming that number is showing me the RAM address. I tested on a 1GB system and it returns a 1xxxxxx value.

So where can I get the Installed Memory size data from?
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg


How to remove advertisement from MSFN

#2
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,327 posts
  • Joined 14-September 05
  • OS:none specified
  • Country: Country Flag
Hmmm... dividing the last value given by 1024 yields a "slightly rounded down" 4096 (4gib).

...and thanks for the REG entries.

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#3
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,902 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

Hmm why didn't I think of that? Using Win32_MemoryArray ...

Round ( EndingAddress / (1024^2))

Gives me "4" on a 4GB PC and "8" on an 8GB PC. This might just be the thing to use.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#4
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,327 posts
  • Joined 14-September 05
  • OS:none specified
  • Country: Country Flag
:w00t: Been a real bad year/decade... a wonder my brain thinks of Captain Obvious items anymore. :wacko:

Glad to assist... and again - thanks!

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#5
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
You could of just used the WMI ComputerSystem to get the amount of installed ram.
Example WMI ComputerSystem Class
Const GB = 1073741824
Const MB = 1048576
Dim Obj, Wmi
Set Wmi = GetObject("winmgmts:\\.\root\CIMV2") 
For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_ComputerSystem") 
 If Obj.TotalPhysicalMemory > Int(GB) Then
  msgbox _
  "Total Physical Memory : " & FormatNumber(Obj.TotalPhysicalMemory / GB,2) & " GB"
 Else
  msgbox _
  "Total Physical Memory : " & FormatNumber(Obj.TotalPhysicalMemory / MB,2) & " MB"
 End If 
Nex



GunSmokingMan



#6
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,902 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

I tried that one and did not get the actual physical memory, but what Windows saw as the total after ignoring the 32bit limitation, and whatever (must be) allocated to video.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#7
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
This is what I get on my 64 bit Win 7

---------------------------

---------------------------
Total Physical Memory : 8.00 GB
---------------------------
OK
---------------------------

So it says I have 8 gigs of ram installed, the exact amount I have on my machine. 4 x 2 GB Ram sticks installed on my machine.

I tried that one and did not get the actual physical memory, but what Windows saw as the total after ignoring the 32bit limitation, and whatever (must be) allocated to video.

So what your saying
Example
I have a video card that uses 1 GIG of ram and I have 8 gigs you expect this WMI Class to subtract 1 GIG of ram and say you have only 7 gigs.
That would give a incorrect amount of installed ram 7 GIGS.


The question ask was TOTAL INSTALL RAM not figure out ram after video card usage, usable ram on a 32 bit OS. This WMI Class give
what ever amount of working RAM sticks that are plug into the RAM Slots.


GunSmokingMan



#8
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,902 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

For this PC that I am working on, has 4GB (4x1GB DDR2) in it, I get these values:

Win32_ComputerSystem: TotalPhysicalMemory = 2613805056 / 1073741824 = 2.434295654296875 GB
Win32_ComputerSystem: TotalPhysicalMemory = 2613805056 / 1048576 = 2492.71875 MB

Task Manager values for Physical Memory (MB)
Total: 2492

It is only a guess for me that my missing ~708MB RAM (3.200GB - 2.492GB) is due to the video card.

I do not know why your WMI query works for you but mine does not. :unsure:
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#9
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
The last time I tried a 32 Bit OS on this computer, I thought I would of had 4 GB on the OS but I only
had approx 3.25 GB of 8 GB usable ram. Maybe the Wmi is reading what is left over as the amount
of Ram minus the Video Card Usage.


GunSmokingMan



#10
Drugwash

Drugwash

    MSFN Expert

  • Member
  • PipPipPipPipPipPip
  • 1,259 posts
  • Joined 21-June 06
  • OS:98SE
  • Country: Country Flag
There's a Windows API to retrieve RAM information.
GlobalMemoryStatus() works on any 32-bit Windows. It can show a maximum of 4GB.
GlobalMemoryStatusEx() works on XP and later, both 32-bit and 64-bit.
More info at MSDN.

Here's a small utility developed by myself in AutoHotkey, that shows amount of RAM, swap file and total load, using GlobalMemoryStatus() :
MemPanel 1.0.1.0

Posted Image

(added screenshot)


Edited by Drugwash, 24 April 2013 - 11:19 AM.


#11
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

Two sequential calls to GlobalMemoryStatus are not guaranteed to return the same information, it is recommended to use GlobalMemoryStatusEx instead.

If you wanted to know the installed memory then perhaps using GetPhysicallyInstalledSystemMemory, (Win Vista+) will do what you want.

For simple scripting the following should show you what's installed in your RAM slots:

Command Prompt

WMIC MEMORYCHIP GET capacity, devicelocator

Powershell Prompt

Get-WmiObject CIM_PhysicalMemory | select capacity,devicelocator | ft -AutoSize


#12
Drugwash

Drugwash

    MSFN Expert

  • Member
  • PipPipPipPipPipPip
  • 1,259 posts
  • Joined 21-June 06
  • OS:98SE
  • Country: Country Flag

Two sequential calls to GlobalMemoryStatus are not guaranteed to return the same information, it is recommended to use GlobalMemoryStatusEx instead.

Relevant info is retrieved from a struct and yes, some values in certain fields will differ, such as free memory, system load, etc. But the amount of physically installed memory should have no reason to differ between calls, unless there's a bug in the API and even that might exist or not according to the OS version running.

I've developed the above application under and mainly for 98SE, therefore I had to use the simple version of the API, not the extended one. For any 32-bit Windows it should work fine. Of course, 64-bit Windows that can accept more than 4GB of RAM should use the extended version of the API instead, for an accurate result.

I could build a x64-compatible version of the application but I have no x64 system to test it on.

#13
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
I made a VB Net app that show ram usage and basic OS information.
Attached File  GsmBasicInfo.png   34KB   4 downloads

This is from this Thread

Get_KeyV1.exe


GunSmokingMan






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users