Get Ram Information OSX

356 Views Asked by At

I need to get RAM information like in system_profiler but I can't find any API to get this on OS X system (10.9 and higher are supported only).

Previously I got the information from the system_profiler

    NSTask *profilerTask = [[NSTask alloc] init];
   [profilerTask setLaunchPath:@"/usr/sbin/system_profiler"];

And parsed it's output what what should I do if system profiler output language is not english ?

//Also it is slow as hell :(

Is there a good way to achieve the RAM hardware info e.g. Number of slots , Ecc ,Type ,Bank, Speed ?

1

There are 1 best solutions below

3
On BEST ANSWER

If you want to specifically get memory information try using:

NSTask *profilerTask = [[NSTask alloc] init];
[profilerTask setLaunchPath:@"/usr/sbin/system_profiler"];
[profilerTask setArguments:[NSArray arrayWithObjects:@"SPMemoryDataType",nil]];

By specifying the data type it should be quicker. To get a list of the available data types use:

$ system_profiler -listDataTypes