Reputation: 103
I am retriving the virtual memory size like below :
-(void)virtualMemory{
struct mach_task_basic_info info;
mach_msg_type_number_t size = MACH_TASK_BASIC_INFO_COUNT;
kern_return_t kerr = task_info(mach_task_self(),
MACH_TASK_BASIC_INFO,
(task_info_t)&info,
&size);
if( kerr == KERN_SUCCESS ) {
NSLog(@"Virtual Memory size (in bytes): %llu", info.virtual_size);
} else {
NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
}
}
Now this gives me Virtual Memory size as - 2784350208
which I am getting using a simulator. Is it possible to get virtual memory used by a specific process?
Upvotes: 0
Views: 292
Reputation: 162722
You would need access to the task_for_pid()
API. That's generally verboten and requires an entitlement to use (see link).
While said entitlement might work in the simulator, I'm not sure it'd even work on your own device and it won't pass submission.
Getting task_for_pid() to work in El Capitan
Upvotes: 1