Memory usage in mac os

While looking at how to get memory usage info in mac, I came across two methods.

  1. Using system command ps:

Here we can get the pid of the process(dgraph) from os.Getpid(). And then use exec package to run ps -ao rss,pid | grep <pid> and get the RSS of the process.

  1. Using task_info struct:

This would require writing some C code to get the task_info struct and then using CGO to get the resident_size field.

What are your thoughts on the best approach? @core-devs


Is there a clear answer to which is more accurate?

Both give accurate numbers on memory usage. Only difference is that one is using system commands, other is by writing C code.

I would say that system command is better then.

1 Like

Yeah, system command seems like a better option.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.