Skip to content

Commit f3e051a

Browse files
committed
runtime: document GOMEMLIMIT in environment variables section
For #48409. Change-Id: Ia6616a377bc4c871b7ffba6f5a59792a09b64809 Reviewed-on: https://go-review.googlesource.com/c/go/+/410734 Run-TryBot: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Chris Hines <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent ef2567c commit f3e051a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/runtime/extern.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ The GOGC variable sets the initial garbage collection target percentage.
1818
A collection is triggered when the ratio of freshly allocated data to live data
1919
remaining after the previous collection reaches this percentage. The default
2020
is GOGC=100. Setting GOGC=off disables the garbage collector entirely.
21-
The runtime/debug package's SetGCPercent function allows changing this
22-
percentage at run time. See https://golang.org/pkg/runtime/debug/#SetGCPercent.
21+
[runtime/debug.SetGCPercent] allows changing this percentage at run time.
22+
23+
The GOMEMLIMIT variable sets a soft memory limit for the runtime. This memory limit
24+
includes the Go heap and all other memory managed by the runtime, and excludes
25+
external memory sources such as mappings of the binary itself, memory managed in
26+
other languages, and memory held by the operating system on behalf of the Go
27+
program. GOMEMLIMIT is a numeric value in bytes with an optional unit suffix.
28+
The supported suffixes include B, KiB, MiB, GiB, and TiB. These suffixes
29+
represent quantities of bytes as defined by the IEC 80000-13 standard. That is,
30+
they are based on powers of two: KiB means 2^10 bytes, MiB means 2^20 bytes,
31+
and so on. The default setting is math.MaxInt64, which effectively disables the
32+
memory limit. [runtime/debug.SetMemoryLimit] allows changing this limit at run
33+
time.
2334
2435
The GODEBUG variable controls debugging variables within the runtime.
2536
It is a comma-separated list of name=val pairs setting these named variables:

0 commit comments

Comments
 (0)