Skip to content

Commit

Permalink
docs: Document system memory limit fallback feature in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KimMachineGun committed Jan 21, 2024
1 parent 2b8484a commit 8ad7e05
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Automatically set `GOMEMLIMIT` to match Linux [cgroups(7)](https://man7.org/linu

See more details about `GOMEMLIMIT` [here](https://tip.golang.org/doc/gc-guide#Memory_limit).

## Notice

Version `v0.5.0` introduces a fallback to system memory limits as an experimental feature when cgroup limits are unavailable. Activate this by setting `AUTOMEMLIMIT_EXPERIMENT=system`.
You can also use system memory limits via `memlimit.FromSystem` provider directly.

This feature is under evaluation and might become a default or be removed based on user feedback.
If you have any feedback about this feature, please open an issue.

## Installation

```shell
Expand Down Expand Up @@ -36,6 +44,15 @@ func init() {
memlimit.WithRatio(0.9),
memlimit.WithProvider(memlimit.FromCgroup),
)
memlimit.SetGoMemLimitWithOpts(
memlimit.WithRatio(0.9),
memlimit.WithProvider(
memlimit.ApplyFallback(
memlimit.FromCgroup,
memlimit.FromSystem,
),
),
)
memlimit.SetGoMemLimitWithEnv()
memlimit.SetGoMemLimit(0.9)
memlimit.SetGoMemLimitWithProvider(memlimit.Limit(1024*1024), 0.9)
Expand Down

0 comments on commit 8ad7e05

Please sign in to comment.