From 8f8ff8d6010954fe5dbd2ce36330fbf1b8451e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 5 May 2020 13:25:56 +0300 Subject: [PATCH] cmd/geth: handle memfixes on 32bit arch with large RAM --- cmd/geth/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 55d2b25b92..2df8e05a26 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -314,6 +314,10 @@ func prepare(ctx *cli.Context) { // Check https://github.com/elastic/gosigar#supported-platforms if runtime.GOOS != "openbsd" { if err := mem.Get(); err == nil { + if 32<<(^uintptr(0)>>63) == 32 && mem.Total > 2*1024*1024*1024 { + log.Warn("Lowering memory allowance on 32bit arch", "available", mem.Total/1024/1024, "addressable", 2*1024) + mem.Total = 2 * 1024 * 1024 * 1024 + } allowance := int(mem.Total / 1024 / 1024 / 3) if cache := ctx.GlobalInt(utils.CacheFlag.Name); cache > allowance { log.Warn("Sanitizing cache to Go's GC limits", "provided", cache, "updated", allowance)