浏览代码

cmd/geth: handle memfixes on 32bit arch with large RAM

Péter Szilágyi 5 年之前
父节点
当前提交
8f8ff8d601
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      cmd/geth/main.go

+ 4 - 0
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)