Getting a computer's ram amount in C++?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Getting a computer's ram amount in C++?

Post by toasty2 »

How can I figure out how much ram a computer has using C++?

Alternatively, if you know a way to do the same in php, that would be helpful.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There's no such standard function/method or standard library for c++, nothing like http://java.sun.com/j2se/1.4.2/docs/api ... axMemory() (and even that's "only" the jvm limit, not necessarily the "real" value).

For win32 there is e.g. GlobalMemoryStatus.
On linux you might read /proc/meminfo or use free -m

What are you trying to achieve?
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

I'm trying to do the same thing I'm doing in this topic, but more natively: viewtopic.php?t=66255&start=0&postdays= ... highlight=
In that topic I'm reading a report generated by CPU-Z. I want to make my own program that can get a few of the basic things CPU-Z can. This is on Windows. CPU-Z However, don't think that I don't want help in that other topic...that is still a viable option for this, and the CPU-Z has many specific things I'm sure I couldn't find out with a simple program.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Well then the example at the manual page for GlobalMemoryStatus should help you.
Post Reply