Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have SunOS 5.10 sparc server. I want to calculate system memory. I can easily find this in Linux using /usr/bin/free command. Can anyone please suggest me if there is any equivalent command in SunOS. It would be better if anyone can give me any Perl script to find the same in below format.

             total       used       free     shared    buffers     cached
Mem:       2257920    1725688     532232          0     354736     766032
Swap:            0          0          0
Total:     2257920    1725688     532232
share|improve this question

migrated from Aug 31 '09 at 13:58

This question came from our site for professional and enthusiast programmers.

You can obtain the physical memory information using kstat -c pages. The numbers are in pages; use the pagesize command to get the page size in bytes. Use swap -s for the current swap utilization.

share|improve this answer
Can you please suggest me any perl code to do find the required details in the same format as we get using free on linux. – Octopus Sep 4 '09 at 10:36
up vote 1 down vote accepted

You can use 'top' which can give you this information, but for this you need to install top package WLtop (if not already installed). You can find this in companion CD or you can download this from

This will be available in companion CD or you need to download from

if this is already installed you can find the default top path would be


If you want to use kstat, you can do below.

totalRAMPages = /usr/bin/kstat -p unix:0:system_pages:physmem
freeRAMPages = /usr/bin/kstat -p unix:0:system_pages:freemem 

pagesize = pagesize

totalRam in MB = totalRAMPages * pagesize / 1024 / 1024
freeRam in MB = freeRAMPages * pagesize / 1024 / 1024

Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.