Pages

Sunday, March 4, 2012

Available, used and free memory in NetBSD

To see how much memory is consumed in NetBSD use cat on /proc/meminfo:

# cat /proc/meminfo
        total:    used:    free:  shared: buffers: cached:
Mem:  506744832 48762880 457981952        0 19550208 34459648
Swap: 135180288        0 135180288
MemTotal:    494868 kB
MemFree:     447248 kB
MemShared:        0 kB
Buffers:      19092 kB
Cached:       33652 kB
SwapTotal:   132012 kB
SwapFree:    132012 kB

The output above show all current memory usage for your real and virtual memory. The unit is Bytes, to get MB or GB you have to divide the number 2 or 3 times by 1024:

# echo 48762880/1024/1024 | bc -l
46.50390625000000000000

In this case I have divided the used memory twice by 1024 to get the used memory in MB.

2 comments:

  1. That only works if you're using a GENERIC kernel afaik. (GENERIC kernels have the linux compat kernel option enabled)

    ReplyDelete
  2. I have removed the COMPAT_LINUX option, recompiled the kernel and /proc/meminfo is still accessible.

    ReplyDelete