How could I find out how much installed RAM a computer has? I would like to use C if possible, to make it portable, but I'd be happy with a Windows answer too(but I know this isn't the windows board )
How could I find out how much installed RAM a computer has? I would like to use C if possible, to make it portable, but I'd be happy with a Windows answer too(but I know this isn't the windows board )
I believe you have to query the BIOS in order to be portable...
This site might be helpful:
http://database.sarang.net/study/OS/...termine_memory
Last edited by itsme86; 09-26-2004 at 12:10 PM.
If you understand what you're doing, you're not learning anything.
on linux you can just open up /proc/meminfo and find all kinds of information regarding memory (including total amount)
It misreports the memory installed in my machine (1GB)Originally Posted by Perspective
Code:MemTotal: 905836 kB
If you understand what you're doing, you're not learning anything.
...interesting. i get this.. (1GB)
MemTotal: 1035424 kB
Well, to be fair I do get this during bootup which I've never bothered fixing:
Code:Linux version 2.6.7 (root@itsme) (gcc version 3.3.4) #1 Mon Jul 5 05:24:34 PDT 2004 BIOS-provided physical RAM map: BIOS-e820: 0000000000000000 - 000000000009fc00 (usable) BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved) BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved) BIOS-e820: 0000000000100000 - 000000003fff0000 (usable) BIOS-e820: 000000003fff0000 - 000000003fff3000 (ACPI NVS) BIOS-e820: 000000003fff3000 - 0000000040000000 (ACPI data) BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved) BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved) BIOS-e820: 00000000ffff0000 - 0000000100000000 (reserved) Warning only 896MB will be used. Use a HIGHMEM enabled kernel. 896MB LOWMEM available.
If you understand what you're doing, you're not learning anything.
Originally Posted by itsme86
Then why are you complaining about /proc/meminfo misreporting the amount of ram you have?
hello, internet!
For Windows, check out GlobalMemoryStatus on the MSDN
(< http://msdn.microsoft.com/library/en...morystatus.asp >)
I wasn't "complaining". I was making a point. And that point was that it doesn't always necessarily tell you how much RAM is installed if your OS is broken, whereas my BIOS query theory should work regardless.Originally Posted by moi
If you understand what you're doing, you're not learning anything.
Is there a portable way to query the BIOS?I believe you have to query the BIOS in order to be portable
And what's the point of knowing about ram that may or may not be there if your OS can't use it?Originally Posted by itsme86
NoOriginally Posted by bithub
hello, internet!
You need an exampe? Hardware inventory checking.Originally Posted by moi
If you understand what you're doing, you're not learning anything.
The theory of querying bios is portable. The code to do so isn't necessarily portable unless you are sticking with a GCC compiler. So code writen for a linux machine can be compiled via mingw and work all find and dandy, however that same code won't compile under VC++ which only handles masm style assembler syntax.
> The theory of querying bios is portable.
Until you come across machines which don't have an IBM-PC compatible BIOS - say a Sun workstation for example.
How do you work out the answer to this question for your GB environment?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.