64-bit memory reporting
64-bit memory reporting
- Subject: 64-bit memory reporting
- From: Eliot Horowitz <email@hidden>
- Date: Tue, 27 Sep 2005 14:11:58 -0400
I'm trying to figure out how to determine how much memory a 64-bit
application is using.
Using the code snippet below, after 2gb, it overflows and gets 17592186042380.
After about 2gb of that, it goes back to 0.
Any help would be appreciated.
Also, if anyone knows of a version of top that works that would be
helpfup as well. The standard version seems to roll over at 4gb.
--------
task_t result;
mach_port_t task;
if ( ( result = task_for_pid( mach_task_self() , getpid() , &task) )
!= KERN_SUCCESS ){
cerr << "error getting task\n";
return;
}
#ifdef __LP64__
task_basic_info_64 ti;
mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
task_flavor_t flavor = TASK_BASIC_INFO_64;
#warning using 64 bit task_info
#else
task_basic_info_32 ti;
mach_msg_type_number_t count = TASK_BASIC_INFO_32_COUNT;
task_flavor_t flavor = TASK_BASIC_INFO_32;
#warning using 32 bit task_info
#endif
if ( ( result = task_info( task , flavor , (task_info_t)&ti, &count
) ) != KERN_SUCCESS ){
cerr << "error getting task_info: " << result << endl;
return;
}
#if !defined(__LP64__)
natural_t size = ti.resident_size;
#else
mach_vm_size_t size = ti.resident_size;
#endif
std::cout
<< "resident_size(b)\t" << size << "\n";
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden