Date: Fri, 5 Apr 2002 08:01:00 +0200 (CEST) From: Stefan Peter <stefan@evil.ki.iif.hu> To: freebsd-questions@FreeBSD.ORG Subject: Virtual Memory question Message-ID: <20020405074847.I29381-200000@evil.ki.iif.hu>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hi All,
Though I'm not member of this mailing-list I was advised to write here to
get some help in the deep details of FreeBSD virtual memory management.
My problem is that I have written a small piece of code (the heart of all
problems :-) which tries to determine the total physical memory, free
physical memory, swap and free swap. I used sysctl() calls to obtain
virtual memory statistics: vmtotal. I use FreeBSD 4.5.
When I ran the code I experienced the following:
> ./a.out
Physmem: 1069248512
VMem: t_vm 2149661375 t_avm 11974 t_rm 254525 t_arm 3188
I.e. the total virtual memory has been extremely large in comparison with
total real memory. I'm not sure I have done the right measurement, but I
found no other virtual memory statistics, than vmtotal.
I also tried to use kvm interface without any success.
I have put my (very basic) code in the appendix.
Any help would be highly appreciated!
Cheers,
Peter Stefan
[-- Attachment #2 --]
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <vm/vm_param.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/vmmeter.h>
int main() {
int i, mib[2];
size_t len;
int pm;
struct vmtotal total;
int pagesize;
len = 2;
sysctlnametomib("hw.physmem", mib, &len);
len = sizeof(pm);
if (sysctl(mib, 2, &pm, &len, NULL, 0) == -1) perror("sysctl");
else if (len > 0) printf("Physmem: %d\n", pm);
mib[0]=CTL_VM;
mib[1]=VM_METER;
len=sizeof total;
if (sysctl(mib, 2, &total, &len, NULL, 0) == -1) perror("sysctl");
else if (len > 0) printf("VMem: t_vm %u t_avm %u t_rm %u t_arm %u\n", total.t_vm, total.t_avm, total.t_rm, total.t_arm);
return 0;
}
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020405074847.I29381-200000>
