From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the amount of installed memory?

Solved!
Go to solution

(This is under Windows OS

 

I am making a benchmarking program to get statistics on performance for some complicated calculations based on computer hardware.

 

What is the best way to obtain the amount of installed RAM programmatically?

How do I tell if the OS is 32 or 64 bit?

 

Thanks! 

0 Kudos
Message 1 of 17
(5,327 Views)

does a call to the getnativesysteminfo function in kernel32.dll give it to you?

 

Here are some details. You can also try the IsWow64Process function, but I don't believe that is exactly what you want. As for the Ram, not sure.

Message Edited by for(imstuck) on 03-10-2010 02:07 PM
0 Kudos
Message 2 of 17
(5,322 Views)

vi.lib\platform\system.llb has memstats.vi

 

 

vi.lib\utility\sysinfo.llb has Get Current platform

 

also look at property node >>> application >>> target stuff

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 17
(5,299 Views)
Solution
Accepted by topic author altenbach

Ben, it doesn't look like the Memstats VI returns the installed memory. It returns a number, but I can't match it to the amount of memory installed in my system. The GetCurrentPlatform seems to only return the OS Name, not whether it's 32-bit or 64-bit. I didn't see anything in the App->Target list that contained this information. At least in 8.2. Haven't checked in 2009.

 


altenbach wrote:

(This is under Windows OS

 

I am making a benchmarking program to get statistics on performance for some complicated calculations based on computer hardware.

 

What is the best way to obtain the amount of installed RAM programmatically?

How do I tell if the OS is 32 or 64 bit?

 

Thanks! 


Define "best". Best in speed? Best in compatibility over multiple versions of the Windows OS? Best in terms of accessing this information without having to delve too much into all sorts of Windows datatypes and DLLs?

 

Would you consider .NET to be a candidate for "best". If so, the amount of installed RAM can be easily acquired using the Microsoft.VisualBasic.Devices.ComputerInfo class:

 

 

As for determining whether your OS is 32-bit or 64-bit are you trying to distinguish between a 32-bit OS on a 64-bit CPU vs a 64-bit OS on a 64-bit CPU? I know the WMI class can be used to get this information, so if you're trying to make that distinction you could look at the Win32_ComputerSystem and Win32_Processor classes. For instance, I believe the following is what you would see:

 

64bit OS on x64processor:
win32_computersystem.systemtype = x64-based pc
win32_processor.addresswidth = 64
win32_processor.architecture = 9
win32_processor.datawidth = 64

32bit OS on x86processor:
win32_computersystem.systemtype = x86-based pc
win32_processor.addresswidth = 32
win32_processor.architecture = 0
win32_processor.datawidth = 32

32bit OS on x64processor:
win32_computersystem.systemtype = x86-based pc
win32_processor.addresswidth = 32
win32_processor.architecture = 9
win32_processor.DataWidth = 64

 

I've attached an example on how to access the classes with .NET. Not pretty, but not overly ugly either.

Message Edited by smercurio_fc on 03-10-2010 03:36 PM
Download All
Message 4 of 17
(5,279 Views)

smercurio_fc wrote:

Define "best".


Just a quick and dirty method that does not require advanced knowledge of the windows guts, works on all OS variations, and does not require fancy code. 😉 (All I want is everything!)

 

I thougth maybe I could read the RAM out of the registry (That's what I do for the CPU info at the moment, see image), but I have not found the key.

 

Here's what I whipped up last night, maybe it's all wrong. I have not tried it on different machines.

 

Thanks for all the suggestions, I'll study them tonight. 😄 

 

 

Message Edited by altenbach on 03-10-2010 01:46 PM
0 Kudos
Message 5 of 17
(5,269 Views)

altenbach wrote:

smercurio_fc wrote:

Define "best".


Just a quick and dirty method that does not require advanced knowledge of the windows guts, works on all OS variations, and does not require fancy code. 😉 (All I want is everything!)

 

I thougth maybe I could read the RAM out of the registry (That's what I do for the CPU info at the moment, see image), but I have not found the key.


There's an HKEY_LOCAL_MACHINE\HARDWARE\RESOURCEMAP\System Resources\Physical Memory\.Translated (yes, that's a period there). It's a packed value. Not sure how to unpack this value.

0 Kudos
Message 6 of 17
(5,254 Views)

I am a bit old-fashioned when it comes to getting the RAM.

 

RAM IT.png

 

Not a lot of useful info returned, but it does give the total installed RAM.

0 Kudos
Message 7 of 17
(5,247 Views)

Darin.K wrote:

I am a bit old-fashioned when it comes to getting the RAM.

 

RAM IT.png

 

Not a lot of useful info returned, but it does give the total installed RAM.


I had already tried that. It doesn't return anything remotely close to the total installed RAM. That returns the total contiguous extended memory, which isn't the same as the total installed RAM. 

0 Kudos
Message 8 of 17
(5,241 Views)

Should have looked more closely at the number.  That is what I get for trying to dust off a command I probably last used on Windows 95.  Now that DOS is off in its own land it is harder to get that info.  There is probably a way to tie into Msinfo32, but that probably reads the Registry.

 

0 Kudos
Message 9 of 17
(5,237 Views)
I'll second .NET as the most reliable option.
-Barrett
CLD
0 Kudos
Message 10 of 17
(5,235 Views)