Skip to content

Instantly share code, notes, and snippets.

@tnachen
Created September 2, 2014 22:38
Show Gist options
  • Save tnachen/cac461f0285acc5eefd5 to your computer and use it in GitHub Desktop.
Save tnachen/cac461f0285acc5eefd5 to your computer and use it in GitHub Desktop.
sysinfo
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sys/sysinfo.h>
#include <errno.h>
int main(int argc, char** argv)
{
struct sysinfo info;
if (sysinfo(&info) != 0) {
return errno;
}
std::cout << "Total:" << info.totalram * info.mem_unit << std::endl;
std::cout << "Free:" << info.freeram * info.mem_unit << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment