We have this System
module already that has cpu_count. I was just thinking that it would be cool if it also could report the RAM on the system.
I came across a stackoverflow post that showed how you can get some of this info on Linux with
#include <sys/sysinfo.h>
int sysinfo(struct sysinfo *info);
struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
unsigned long totalhigh; /* Total high memory size */
unsigned long freehigh; /* Available high memory size */
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
};
I don’t know C, so I’m not sure how this works, but as I understand it, sys/sysinfo
doesn’t exist on Mac (and probably not on Windows either). So having something built in that already understands the current system to give us this information would be pretty helpful. Even if it was just something like total RAM to start could be cool. System.total_ram