I'm working on an embedded device with 512 MiB of RAM. When I start a go executable compiled with gccgo, it allocates over 800-900 MiB of memory (VmData) right off the bat. This is around 180% of the memory available on the device. I would like to reduce this to a value that is reasonable for my device, but after hours of research, I cannot pinpoint where this memory is being allocated, what it is for, nor how I can tweak the amount. I'm cross compiling to i686 on ubuntu with i686-linux-gnu like so: > #!/bin/bash > > TOOLCHAIN_PREFIX=i686-linux-gnu > OPTIMIZATION_FLAG="-O3" > > CGO_ENABLED=1 \ > CC=${TOOLCHAIN_PREFIX}-gcc-8 \ > CXX=${TOOLCHAIN_PREFIX}-g++-8 \ > AR=${TOOLCHAIN_PREFIX}-ar \ > GCCGO=${TOOLCHAIN_PREFIX}-gccgo-8 \ > CGO_CFLAGS="-g ${OPTIMIZATION_FLAG}" \ > CGO_CPPFLAGS="" \ > CGO_CXXFLAGS="-g ${OPTIMIZATION_FLAG}" \ > CGO_FFLAGS="-g ${OPTIMIZATION_FLAG}" \ > CGO_LDFLAGS="-g ${OPTIMIZATION_FLAG}" \ > GOOS=linux \ > GOARCH=386 \ > go build -x \ > -compiler=gccgo \ > -gccgoflags=all="-static -g ${OPTIMIZATION_FLAG}" \ > $1 My gcc version is 8.2.0: > $ i686-linux-gnu-gccgo-8 --version > i686-linux-gnu-gccgo-8 (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0 > Copyright (C) 2018 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The go executable that allocates 800-900 MiB of RAM is: > package main > > import ( > "fmt" > "time" > ) > > func main() { > fmt.Println("hello world") > time.Sleep(1000000000 * 5) > } I've played with the GOGC environment variable, but that only makes VmData wiggle a few MiB one way or the other. I also tried looking through the gccgo/libgo source code, but I got lost quickly. If anyone could set me on the right path, I would be grateful.