Hi all,
Forget the following :
- hobbit client freebsd-memory.c
We got a box with more than 4 GB of memory, the freebsd-memory.c is using integer, so the value returned is wrong and negative on this box.
So I just modified the int to a long unsigned, and also the prinf statement, now it works fine.
int main(int argc, char *argv[]) { int hw_physmem[] = { CTL_HW, HW_PHYSMEM }; long unsigned physmem;
int hw_pagesize[] = { CTL_HW, HW_PAGESIZE };
int pagesize;
int vm_vmtotal[] = { CTL_VM, VM_METER };
struct vmtotal vmdata;
size_t len;
int result;
len = sizeof(physmem);
result = sysctl(hw_physmem, sizeof(hw_physmem) /
sizeof(*hw_physmem), &physmem, &len, NULL, 0); if (result != 0) return 1;
len = sizeof(pagesize);
result = sysctl(hw_pagesize, sizeof(hw_pagesize) /
sizeof(*hw_pagesize), &pagesize, &len, NULL, 0); if (result != 0) return 1;
len = sizeof(vmdata);
result = sysctl(vm_vmtotal, sizeof(vm_vmtotal) /
sizeof(*vm_vmtotal), &vmdata, &len, NULL, 0);
// printf("Pagesize:%d\n", pagesize);
printf("Total:%lu\n", (physmem / (1024 * 1024)));
printf("Free:%d\n", (pagesize / 1024)*(vmdata.t_free / 1024));
}
Thanks for this great product, Laurent Grilli
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. This communication is from TI Automotive.