gotosocial/vendor/github.com/KimMachineGun/automemlimit
dependabot[bot] ab7f518f57
[chore]: Bump github.com/KimMachineGun/automemlimit from 0.2.5 to 0.2.6 (#1723)
Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.2.5 to 0.2.6.
- [Release notes](https://github.com/KimMachineGun/automemlimit/releases)
- [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.2.5...v0.2.6)

---
updated-dependencies:
- dependency-name: github.com/KimMachineGun/automemlimit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 11:01:36 +02:00
..
memlimit [chore]: Bump github.com/KimMachineGun/automemlimit from 0.2.5 to 0.2.6 (#1723) 2023-05-01 11:01:36 +02:00
.gitignore [feature] Inherit resource limits from cgroups (#1336) 2023-01-17 20:59:04 +00:00
automemlimit.go [feature] Inherit resource limits from cgroups (#1336) 2023-01-17 20:59:04 +00:00
LICENSE [feature] Inherit resource limits from cgroups (#1336) 2023-01-17 20:59:04 +00:00
README.md [feature] Inherit resource limits from cgroups (#1336) 2023-01-17 20:59:04 +00:00

automemlimit

Go Reference Go Report Card Test

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

See more details about GOMEMLIMIT here.

Installation

go get github.com/KimMachineGun/automemlimit@latest

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"

or

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)
}