memory – github.com/pbnjay/memory Index | Examples | Files

package memory

import "github.com/pbnjay/memory"

Package memory provides a single method reporting total system memory accessible to the kernel.

Index

Examples

Functions

func FreeMemory

func FreeMemory() uint64

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.

Example

Code:play 

package main

import (
	"fmt"

	"github.com/pbnjay/memory"
)

func main() {
	fmt.Printf("Free system memory: %d\n", memory.FreeMemory())
}

func TotalMemory

func TotalMemory() uint64

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.

Example

Code:play 

package main

import (
	"fmt"

	"github.com/pbnjay/memory"
)

func main() {
	fmt.Printf("Total system memory: %d\n", memory.TotalMemory())
}

Source Files

doc.go stub.go

Version
v0.0.0-20210728143218-7b4eea64cf58 (latest)
Published
Jul 28, 2021
Platform
js/wasm
Last checked
now

Tools for package owners.