#include <stdio.h>
#include <sys/pstat.h>
main()
{
struct pst_static buf;
struct pst_dynamic dyn;
pstat_getstatic(&buf,sizeof(struct pst_static),1,0);
pstat_getdynamic(&dyn,sizeof(struct pst_dynamic),1,0);
printf("Total  Phys memory=%dMB\n",buf.page_size/1024*buf.physical_memory/1024);
printf("Total  Virt memory=%dMB\n",buf.page_size/1024*dyn.psd_vm/1024);
printf("Active Virt memory=%dMB\n",buf.page_size/1024*dyn.psd_avm/1024);
printf("Total  Real memory=%dMB\n",buf.page_size/1024*dyn.psd_rm/1024);
printf("Active Real memory=%dMB\n",buf.page_size/1024*dyn.psd_arm/1024);
printf("Free        memory=%dMB\n",buf.page_size/1024*dyn.psd_free/1024);
}
