Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion memory_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package memory
Expand Down Expand Up @@ -25,5 +26,9 @@ func sysFreeMemory() uint64 {
// If this is a 32-bit system, then these fields are
// uint32 instead of uint64.
// So we always convert to uint64 to match signature.
return uint64(in.Freeram) * uint64(in.Unit)
// Buffer/cache ram is included on linux since the kernel
// will free this memory for applications if needed, and tends
// to use almost all free memory for itself when it can.
// https://pkg.go.dev/syscall#Sysinfo_t
return (uint64(in.Freeram) + uint64(in.Bufferram)) * uint64(in.Unit)
}