package memory
Import Path
github.com/pbnjay/memory (on go.dev)
Dependency Relation
imports one package, and imported by one package
Involved Source Files
Package memory provides a single method reporting total system memory
accessible to the kernel.
memory_linux.go
Code Examples
package main
import (
"fmt"
"github.com/pbnjay/memory"
)
func main() {
fmt.Printf("Free system memory: %d\n", memory.FreeMemory())
}
package main
import (
"fmt"
"github.com/pbnjay/memory"
)
func main() {
fmt.Printf("Total system memory: %d\n", memory.TotalMemory())
}
Package-Level Functions (total 2)
FreeMemory returns the total free system memory in bytes.
The total free memory is installed physical memory size minus reserved
areas for other applications running on the same system.
If free memory size could not be determined, then 0 is returned.
TotalMemory returns the total accessible system memory in bytes.
The total accessible memory is installed physical memory size minus reserved
areas for the kernel and hardware, if such reservations are reported by
the operating system.
If accessible memory size could not be determined, then 0 is returned.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |