Documentation
¶
Index ¶
- Constants
- Variables
- func ForceReadMemStats() *runtime.MemStats
- func GetMemTotalIgnoreErr() uint64
- func InitMemoryHook()
- func InstanceMemUsed() (uint64, error)
- func MemTotalCGroup() (uint64, error)
- func MemTotalNormal() (uint64, error)
- func MemUsedCGroup() (uint64, error)
- func MemUsedNormal() (uint64, error)
- func ReadMemStats() (memStats *runtime.MemStats)
Constants ¶
const ReadMemInterval = 300 * time.Millisecond
ReadMemInterval controls the interval to read memory stats.
Variables ¶
var MemTotal func() (uint64, error)
MemTotal returns the total amount of RAM on this system
var MemUsed func() (uint64, error)
MemUsed returns the total used amount of RAM on this system
var (
ServerMemoryLimit atomic.Uint64
)
Process global variables for memory limit.
Functions ¶
func ForceReadMemStats ¶
ForceReadMemStats is to force read memory stats.
func GetMemTotalIgnoreErr ¶
func GetMemTotalIgnoreErr() uint64
GetMemTotalIgnoreErr returns the total amount of RAM on this system/container. If error occurs, return 0.
func InitMemoryHook ¶
func InitMemoryHook()
InitMemoryHook initializes the memory hook. It is to solve the problem that tidb cannot read cgroup in the systemd. so if we are not in the container, we compare the cgroup memory limit and the physical memory, the cgroup memory limit is smaller, we use the cgroup memory hook. ref https://github.com/pingcap/tidb/pull/48096/
func InstanceMemUsed ¶
InstanceMemUsed returns the memory usage of this process
func MemTotalCGroup ¶
MemTotalCGroup returns the total amount of RAM on this system in container environment.
func MemTotalNormal ¶
MemTotalNormal returns the total amount of RAM on this system in non-container environment.
func MemUsedCGroup ¶
MemUsedCGroup returns the total used amount of RAM on this system in container environment.
func MemUsedNormal ¶
MemUsedNormal returns the total used amount of RAM on this system in non-container environment.
func ReadMemStats ¶
ReadMemStats read the mem stats from runtime.ReadMemStats
Types ¶
This section is empty.