4

I need to show physical memory statistics in Solaris, like total memory, used and free memory. Don't want to create a script, so is it possible to get all these details using commandline only?

  • Beware that the concept of "free memory" on Solaris with ZFS has become obscure given that ZFS will use whatever physical is available (for its cache) and release if some application asks for memory. So on a system with ZFS you'll almost always see all memory as being used which is technically true. The design idea is that unused RAM is a waste of money. If nobody is using it then the kernel (in this case ZFS) might as well make use of it ... until some process actually needs it. – peterh Sep 29 '14 at 8:26
5

To see installed memory you can use this command:

$ prtconf | grep Memory
Memory size: 65408 Megabytes

There's also prtdiag -v | grep Memory.

Additional methods are shown here: Used memory on Solaris 10.

  • prtdiag -v | grep Memory This is not working for me...and also wanted to print free and available physical memory. – user85387 Sep 29 '14 at 15:56
0

root@solaris11:~# vmstat -p

memory           page          executable      anonymous      filesystem
   swap  free  re  mf  fr  de  sr  epi  epo  epf  api  apo  apf  fpi  fpo  fpf
 3430236 2679108 67 533 0   0 127    0    0    0    0    0    0    0    0    0
0

Memory management is complicated. For example in vmstat you will see a column sr, which is the scan rate. When a Solaris server starts running out of memory it starts scanning for pages and that value shows how quickly it's scanning. If you have a memory-critical application then that must be 0, if it isn't then you need to add more memory.

To come back to your original question, this is what you're looking for, it needs to be run as root:

root@vru-ws1 # echo "::memstat" | mdb -k
Page Summary                Pages                MB  %Tot
------------     ----------------  ----------------  ----
Kernel                     677215              5290   16%
ZFS File Data             2280669             17817   55%
Anon                      1004294              7846   24%
Exec and libs               39636               309    1%
Page cache                   4279                33    0%
Free (cachelist)            20806               162    0%
Free (freelist)            101869               795    2%
Total                     4128768             32256
root@vru-ws1 #

But as with all memory matters, that needs interpretation. For example ZFS is using 55% of RAM, but to be honest it could get away with a lot less, it's just taking it because it can. If something else needs it then the OS will reduce ZFS's file data; to a point, beyond which it will affect ZFS performance. If anyone wants me to further elaborate I'd be happy to do so.

Lastly, Oracle has an excellent article which covers this and more besides. You'll need a login on Oracle support, but not a subscription.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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