ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

取消
显示结果 
搜索替代 
您的意思是: 

How to get the amount of installed memory?

已解决!
转到解答

(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 项奖励
1 条消息(共 17 条)
7,123 次查看

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 项奖励
2 条消息(共 17 条)
7,118 次查看

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 项奖励
3 条消息(共 17 条)
7,095 次查看
解答
接受人 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
下载全部
4 条消息(共 17 条)
7,075 次查看

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 项奖励
5 条消息(共 17 条)
7,065 次查看

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 项奖励
6 条消息(共 17 条)
7,050 次查看

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 项奖励
7 条消息(共 17 条)
7,043 次查看

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 项奖励
8 条消息(共 17 条)
7,037 次查看

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 项奖励
9 条消息(共 17 条)
7,033 次查看
I'll second .NET as the most reliable option.
-Barrett
CLD
0 项奖励
10 条消息(共 17 条)
7,031 次查看