memory

package
v0.0.0-...-c5bc0ce Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

Limiter represent memory limiter.

func New

func New(cgroupPath, cgroupName string) *Limiter

New create new implementation of `cgroup.Memory`

func (*Limiter) Context

func (limiter *Limiter) Context() context.Context

Context return new context that cancelled when the total memory usage of processes exceeding the limit.

func (*Limiter) Limit

func (limiter *Limiter) Limit(bytes uint64) error

Limit limit maximum memory usage of processes inside cgroup.

func (*Limiter) Prepare

func (limiter *Limiter) Prepare() error

Prepare create new cgroup tree inside memory subsystem. When old cgroup with same name already exists, it will be removed. TODO: use memory swap cgroup config

func (*Limiter) Put

func (limiter *Limiter) Put(process *os.Process) error

Put will put `process` inside cgroup in memory subsystem. This basically declare that you want `process`'s memory usage to be monitored, throttled, and killed when exceeding the limit of `Limiter`.

func (*Limiter) Throttle

func (limiter *Limiter) Throttle(throttle uint64) error

Throttle throttle memory usage of processes inside cgroup. Process will not killed when exceeding this limit. TODO: also throttle swap memory

func (*Limiter) Usage

func (limiter *Limiter) Usage() uint64

Usage returns maximum memory usage.

Jump to

Keyboard shortcuts

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