2

GitHub - KimMachineGun/automemlimit: Automatically set GOMEMLIMIT to match Linux...

 2 years ago
source link: https://github.com/KimMachineGun/automemlimit
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

automemlimit

Automatically set GOMEMLIMIT to match Linux cgroups(7) memory limit.

See more details about GOMEMLIMIT here.

Installation

go get -u github.com/KimMachineGun/automemlimit

Usage

package main

// By default, it sets `GOMEMLIMIT` to 90% of cgroup's memory limit.
// You can find more details of its behavior from the doc comment of memlimit.SetGoMemLimitWithEnv.
import _ "github.com/KimMachineGun/automemlimit"
package main

import "github.com/KimMachineGun/automemlimit/memlimit"

func init() {
	memlimit.SetGoMemLimitWithEnv()
	memlimit.SetGoMemLimit(0.9)
	memlimit.SetGoMemLimitWithProvider(memlimit.Limit(1024*1024), 0.9)
	memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroup, 0.9)
	memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupV1, 0.9)
	memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupV2, 0.9)
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK