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 free in the same memory. P>

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:

  # 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); }  

It produces total and free memory. See also HP-UX manual for


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -