プロジェクト
GitHubで見る
KimMachineGun/automemlimit
概要
Linux cgroups(7) のメモリ制限に合わせて GOMEMLIMIT を自動設定します。
その他のプロジェクト計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- +1
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルautomemlimit
Automatically set GOMEMLIMIT based on the Linux cgroups(7) memory limit.
See more details about GOMEMLIMIT here.
Notice
Version v1.0.0 simplifies the public API and improves cgroup memory limit detection.
Key changes from v0.x:
memlimit.Setreplaces thememlimit.SetGoMemLimit*functionsmemlimit.Setreturns the previousGOMEMLIMITinstead of0when configuration is skipped or an error occursmemlimit.SetsetsGOMEMLIMITtomath.MaxInt64when the provider returnsmemlimit.ErrNoLimitmemlimit.FromCgroupreplaces the version-specific cgroup providersmemlimit.WithEnv,AUTOMEMLIMIT_EXPERIMENT, andAUTOMEMLIMIT_DEBUGwere removed- Use
memlimit.FromSystemfor system memory fallback
- Use
memlimit.WithRefreshIntervalnow takes acontext.Contextfor cancellationmemlimit.WithMinwas added to set a lower bound forGOMEMLIMIT
Installation
go get github.com/KimMachineGun/automemlimit@latest
Usage
package main
// Importing this package sets GOMEMLIMIT automatically from the cgroup memory limit.
// By default, it sets GOMEMLIMIT to 90% of the cgroup memory limit.
// Set the AUTOMEMLIMIT environment variable to a ratio in (0.0, 1.0], or "off".
import _ "github.com/KimMachineGun/automemlimit"
For more control, use memlimit.Set directly:
package main
import (
"log"
"github.com/KimMachineGun/automemlimit/memlimit"
)
func main() {
_, err := memlimit.Set(
memlimit.WithRatio(0.9),
memlimit.WithMin(100*1024*1024),
memlimit.WithProvider(
memlimit.ApplyFallback(
memlimit.FromCgroup,
memlimit.FromSystem,
),
),
)
if err != nil {
log.Fatal(err)
}
}
関連プロジェクトを探す
読み込み中…