37

What is equivalent of Linux's 'free' command on FreeBSD v8.1?

I am calling 'free' from my application and reporting the results in my application's log file. What would be the replacement when porting to FreeBSD v8.1?

Here is a sample run of 'free' on Linux:

[centos4x32 ~] free
             total       used       free     shared    buffers     cached
Mem:        774452     733044      41408          0      98040     328880
-/+ buffers/cache:     306124     468328
Swap:      2031608        224    2031384
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
WilliamKF
  • 41,123
  • 68
  • 193
  • 295

6 Answers6

41
  • vmstat has default output which is similar in nature and takes many options that give extremely detailed information, eg vmstat -m
  • swapinfo would cover the swap part
  • top -d1 causes top to print one screen and exit, and the banner is very similar to free. Use top -d1 | head -n 7 to see only the banner
Ben Jackson
  • 90,079
  • 9
  • 98
  • 150
13

Maybe freecolor command is a choice. Install it:

# cd /usr/ports/sysutils/freecolor
# make install clean

Use it:

# freecolor
Physical  : [#################################..] 94%   (1907820/2018396)
Swap      : [###################################] 100%  (1048540/1048540)
# freecolor -m -o
             total       used       free     shared    buffers     cached
Mem:          1971        107       1863          0          0          0
Swap:         1023          0       1023

Please refer FreeBSD find out RAM size Including Total Amount of Free and Used Memory Size.

Nan Xiao
  • 16,671
  • 18
  • 103
  • 164
10

vmstat -s gives some more human-readable or script-parseable information, including listing the page size. Otherwise, it gives output in numbef of pages. With no options, vmstat gives a brief summary.

The vmstat command also exists on NetBSD.

Brian Minton
  • 3,377
  • 3
  • 35
  • 41
3

just use old good htop

install htop

 pkg install htop

to run

htop
xsor
  • 1,074
  • 11
  • 11
2

Other option:

# vmstat fre

procs      memory      page                      faults         cpu
 r b w     avm    fre   flt  re  pi  po    fr  sr   in   sy   cs us sy id
 0 0 0  13475M    24M   689   1   2   0   344 394 14693 37734 60809  7 43 50
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
miguelcm
  • 21
  • 3
1

You can use this script.

# fetch http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
# mv freebsd-memory.pl.txt /usr/local/bin/free
# chmod +x /usr/local/bin/free  

source: http://www.cyberciti.biz/faq/freebsd-command-to-get-ram-information/

David Okwii
  • 7,352
  • 2
  • 36
  • 29