469,125 Members | 1,676 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

Memory Used - in Solaris using C programming

How do I get the used-memory of a solaris running system using C code ?

Thanks!
Mar 5 '07 #1
4 4702
Could you refine the problem more ??

Thnkx !
Mar 5 '07 #2
drhowarddrfine
7,435 Expert 4TB
See if 'top' does what you want.
Mar 5 '07 #3
here is sample code to get memory information from solaris in C

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <unistd.h>
  3.  
  4. int main()
  5. {
  6.  
  7.    long numPages, pageSize, freePages, totalSize, totalUsed, totalFree;
  8.  
  9.    numPages = sysconf(_SC_PHYS_PAGES)/1024;
  10.    pageSize = sysconf(_SC_PAGESIZE)/1024;
  11.    freePages = sysconf( _SC_AVPHYS_PAGES)/1024;
  12.    totalSize = numPages * pageSize;
  13.    totalFree = pageSize * freePages;
  14.    totalUsed = totalSize - totalFree;
  15.  
  16.    printf("total memory == %u MB\n",totalSize);
  17.    printf("total free memory == %u MB\n",totalFree);
  18.    printf("total used memory == %u MB\n",totalUsed);
  19.  
  20.    return(0);
  21.  
  22. }
  23.  
  24.  
Mar 21 '07 #4
do u know the cpu utililization program in c for linux....
Apr 20 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Attila.Rajmund.Nohl | last post: by
3 posts views Thread by Rekha | last post: by
6 posts views Thread by Jay | last post: by
5 posts views Thread by Per B. Sederberg | last post: by
12 posts views Thread by Tony | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.