memoryKit

package
v2.1.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetMemoryStat func() (*mem.VirtualMemoryStat, error) = mem.VirtualMemory

GetMemoryStat 获取当前瞬间的内存状态.

PS: (1) Total = Available + Used

Functions

func GetUsedMemoryPercent

func GetUsedMemoryPercent() (float64, error)

GetUsedMemoryPercent

@return e.g. (50.903940200805664, nil)

func MemoryStatToString

func MemoryStatToString(stat *mem.VirtualMemoryStat) string

MemoryStatToString

e.g. () => "total: 32 GiB, available: 18 GiB, used: 14 GiB, free: 9.9 GiB, used percent: 43.06%", nil

func SetSoftMemoryLimit

func SetSoftMemoryLimit(limit uint64) (int64, error)

SetSoftMemoryLimit 软内存限制(soft memory limit)

PS: (1) This limit will be respected even if GOGC=off (or, if SetGCPercent(-1) is executed). (2) 默认memory limit是math.MaxInt64(即第一次调用debug.SetMemoryLimit()的返回值为math.MaxInt64).

@param limit 单位: B(byte;字节) @return 之前的内存限制

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL