Reputation: 2002
I am trying to get total and if possible free memory of the system by C. It should be system-independent.
To initiate the discussion I can suggest getpagesize() method to get page-size. Anyone can help about number of memory pages would be good.
Upvotes: 1
Views: 1228
Reputation: 78923
Not only that memory handling is system dependent as others already stated, such a thing as the "total amount of memory" simply doesn't exist as a clear concept in many cases. There is
Upvotes: 2
Reputation: 10880
If by "system-independent" you mean OS independent, then I really doubt you'll find any single command to work on all platforms.
If you want system specific:
For Linux you could also try the sysconf
function in unistd.h
Upvotes: 1
Reputation: 32240
There is no way of doing this in a system independent fashion. The language has no concept of memory pages, or where and how it's stored.
Upvotes: 3
Reputation: 96109
There isn't a system independent way of doing this because it is obviously system dependent!
Upvotes: 5