[英]OSX - how to get memory usage of NSTask?
I need to start a external program and wait until it ends. 我需要启动一个外部程序,然后等待它结束。 After it was running I nead peak memory usage and CPU time oder CPU tiks.
运行后,我需要消除峰值内存使用量和CPU时间,或者CPU麻烦。
How can I do this in C / Objective-C on OSX 10.11? 如何在OSX 10.11的C / Objective-C中执行此操作?
I looked at NSTask, but I have no idea how to get peak memory usage and CPU time. 我看了NSTask,但是我不知道如何获得峰值内存使用率和CPU时间。
You can get the PID by calling -processIdentifier
and then use Mach's task_info()
function to get the information you seek. 您可以通过调用
-processIdentifier
来获取PID,然后使用Mach的task_info()
函数来获取所需的信息。 See: Memory used by a process under mac os x 请参阅: Mac OS X下进程使用的内存
I believe task info should be available until the process is waited, so just be sure to do that after the process finishes. 我相信任务信息应该在等待过程之前可用,因此请确保在过程完成后再执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.