questions regarding "Inactive", "Cache" and "Buffers" memory

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

questions regarding "Inactive", "Cache" and "Buffers" memory

Martin T
Hi,

FreeBSD "top" utility categorizes memory into "Active", "Inact",
"Wired", "Cache", "Buf" and "Free" sections. For example:

Mem: 125M Active, 42M Inact, 51M Wired, 17M Cache, 34M Buf, 2720K Free
Swap: 512M Total, 512M Free


Those sections should have following meanings:

Active: Memory currently being used by processes.
Inactive: Memory that was used by processes that are no longer
running, but is cached since it may be used again.
Wired: Memory in use by the FreeBSD kernel. This memory cannot be swapped out.
Cache: Memory being used to cache data. Can be freed immediately if required.
Buffers: Disk(HDD/SSD) cache.
Free: Completely free and ready to use.


Questions:

1) Is it possible to flush "Inactive", "Cache" or "Buffers" memory? Or
can this be done only be kernel automatically?

2) What is the difference between "Cache" and "Buffers" memory?



thanks,
Martin
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-i386
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: questions regarding "Inactive", "Cache" and "Buffers" memory

Bruce Evans-4
On Tue, 6 Oct 2015, Martin T wrote:

This is not really i386-specific.

> FreeBSD "top" utility categorizes memory into "Active", "Inact",
> "Wired", "Cache", "Buf" and "Free" sections. For example:
>
> Mem: 125M Active, 42M Inact, 51M Wired, 17M Cache, 34M Buf, 2720K Free
> Swap: 512M Total, 512M Free
>
> Those sections should have following meanings:

"should" according to top's UI?  Some of them are too FreeBSD-specific
to match a general UI.

> Active: Memory currently being used by processes.
> Inactive: Memory that was used by processes that are no longer
> running, but is cached since it may be used again.
> Wired: Memory in use by the FreeBSD kernel. This memory cannot be swapped out.
> Cache: Memory being used to cache data. Can be freed immediately if required.
> Buffers: Disk(HDD/SSD) cache.

"Buf" is a generic idea, but top only displays a FreeBSD buffer variable
that is unrelated to top's idea of what it is, and is among the least useful
of FreeBSD buffer-related variables.  It is what is given by the vfs.bufspace
sysctl.

Most of the disk cache lives in VMIO pages which are counted under
"Inact".  Under some loads (especially light ones), "Inact" is
mostly for the disk cache, but it is not easy to say exactly when this
applies.

"Buf" is just the amount of virtual memory currently used for
mapping VMIO pages.  In normal use (not using zfs) after the system
has read a lot off disks, it is much smaller than the amount buffered
in VMIO pages.  The mapping may be sparse or fragmented, so it may be
much larger than the amount mapped.  It is limited to a fixed amount
given by the vfs.maxbufspace syscall.  This value is even less
interesting since it is fixed at boot time and is determined by the
amount of memory unless it is manually configured.  But unless the
mapping is very sparse or fragmented, after the buffer cache warms up
bufspace is much the same as maxbufspace.  So all that the dynamic
bufspace tells you most of the time is how ineffective the mapping is.

> Free: Completely free and ready to use.
>
> Questions:
>
> 1) Is it possible to flush "Inactive", "Cache" or "Buffers" memory? Or
> can this be done only be kernel automatically?

I don't know of any way except unmounting a file system.  That moves
all pages for buffering the file system out of "Inact", and any of
these that are mapped into the buffer cache out of "Buf".

zfs doesn't use the normal mechism, so I think neither "Inact" or
"Buf" is relevant for it.  It now has its own line on the top display.

> 2) What is the difference between "Cache" and "Buffers" memory?

"Cache" is even more technical and unsuitable for putting in the top
display than "Buf".  Since it is a FreeBSD (mach vm) thing, users
shouldn't even detect top to display it.  This seems to be fixed in
-current -- "Cache" is just not displayed.  It usually has a small
value (28K on my old system) so was best ignored.

"Wired" and "Inact" are also techical vm things, but they are worth
displaying since they have interesting values that can be partly
understood without knowing all the details.

Bruce
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-i386
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: questions regarding "Inactive", "Cache" and "Buffers" memory

Martin T
Thanks for explanation! This is probably a huge simplification, but am
I correct that FreeBSD kernel will automatically allocate memory from
"Inactive", "Cache" and "Buffers" pools to "Active" and "Wired" if
this is needed?


Martin

On 10/6/15, Bruce Evans <[hidden email]> wrote:

> On Tue, 6 Oct 2015, Martin T wrote:
>
> This is not really i386-specific.
>
>> FreeBSD "top" utility categorizes memory into "Active", "Inact",
>> "Wired", "Cache", "Buf" and "Free" sections. For example:
>>
>> Mem: 125M Active, 42M Inact, 51M Wired, 17M Cache, 34M Buf, 2720K Free
>> Swap: 512M Total, 512M Free
>>
>> Those sections should have following meanings:
>
> "should" according to top's UI?  Some of them are too FreeBSD-specific
> to match a general UI.
>
>> Active: Memory currently being used by processes.
>> Inactive: Memory that was used by processes that are no longer
>> running, but is cached since it may be used again.
>> Wired: Memory in use by the FreeBSD kernel. This memory cannot be swapped
>> out.
>> Cache: Memory being used to cache data. Can be freed immediately if
>> required.
>> Buffers: Disk(HDD/SSD) cache.
>
> "Buf" is a generic idea, but top only displays a FreeBSD buffer variable
> that is unrelated to top's idea of what it is, and is among the least
> useful
> of FreeBSD buffer-related variables.  It is what is given by the
> vfs.bufspace
> sysctl.
>
> Most of the disk cache lives in VMIO pages which are counted under
> "Inact".  Under some loads (especially light ones), "Inact" is
> mostly for the disk cache, but it is not easy to say exactly when this
> applies.
>
> "Buf" is just the amount of virtual memory currently used for
> mapping VMIO pages.  In normal use (not using zfs) after the system
> has read a lot off disks, it is much smaller than the amount buffered
> in VMIO pages.  The mapping may be sparse or fragmented, so it may be
> much larger than the amount mapped.  It is limited to a fixed amount
> given by the vfs.maxbufspace syscall.  This value is even less
> interesting since it is fixed at boot time and is determined by the
> amount of memory unless it is manually configured.  But unless the
> mapping is very sparse or fragmented, after the buffer cache warms up
> bufspace is much the same as maxbufspace.  So all that the dynamic
> bufspace tells you most of the time is how ineffective the mapping is.
>
>> Free: Completely free and ready to use.
>>
>> Questions:
>>
>> 1) Is it possible to flush "Inactive", "Cache" or "Buffers" memory? Or
>> can this be done only be kernel automatically?
>
> I don't know of any way except unmounting a file system.  That moves
> all pages for buffering the file system out of "Inact", and any of
> these that are mapped into the buffer cache out of "Buf".
>
> zfs doesn't use the normal mechism, so I think neither "Inact" or
> "Buf" is relevant for it.  It now has its own line on the top display.
>
>> 2) What is the difference between "Cache" and "Buffers" memory?
>
> "Cache" is even more technical and unsuitable for putting in the top
> display than "Buf".  Since it is a FreeBSD (mach vm) thing, users
> shouldn't even detect top to display it.  This seems to be fixed in
> -current -- "Cache" is just not displayed.  It usually has a small
> value (28K on my old system) so was best ignored.
>
> "Wired" and "Inact" are also techical vm things, but they are worth
> displaying since they have interesting values that can be partly
> understood without knowing all the details.
>
> Bruce
>
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-i386
To unsubscribe, send any mail to "[hidden email]"