c - how to compute total free physical memory on hp-ux -
I want to do a shell script or C program that calculates the command as P> Is there a CPI that allows the user to calculate all free memory? Or ultimately there is a way to determine all the physical memory available on the system, then use all the memory to be used and calculate free PHYS memory? I do this from this small program: It produces total and free memory. See also HP-UX manual for free in the same memory. P>
# Include & lt; Stdlib.h & gt; # Include & lt; Stdio.h & gt; #include & lt; String.h & gt; # Include & lt; Sys / pstat.h & gt; Int main () {struct pst_static pst; Struct pst_dynamic psd; Memset (& amp; pst, 0, size (struct pst_static)); Pstat_getstatic (& amp; pst, sizeof (pst), (size_t) 1, 0); Memset (and psd, 0, size (struct pst_dynamic)); Pstat_getdynamic (and psd, sizeof (psd), (size_t) 1, 0); Printf ("Total Memory:% LDD \ n", pst.physical_memory * pst.page_size); Printf ("Free Memory:% LDD \ n", psd.psd_free * pst.page_size); }
Comments
Post a Comment