diff --git a/contrib/mobile/mobile.go b/contrib/mobile/mobile.go index 4c1a8ef9a..6ceccb30f 100644 --- a/contrib/mobile/mobile.go +++ b/contrib/mobile/mobile.go @@ -5,7 +5,6 @@ import ( "encoding/json" "net" "regexp" - "runtime/debug" "github.com/gologme/log" @@ -43,7 +42,7 @@ func (m *Yggdrasil) StartAutoconfigure() error { // StartJSON starts a node with the given JSON config. You can get JSON config // (rather than HJSON) by using the GenerateConfigJSON() function func (m *Yggdrasil) StartJSON(configjson []byte) error { - debug.SetMemoryLimit(1024 * 1024 * 40) + setMemLimitIfPossible() logger := log.New(m.log, "", 0) logger.EnableLevel("error") diff --git a/contrib/mobile/mobile_mem_go120.go b/contrib/mobile/mobile_mem_go120.go new file mode 100644 index 000000000..853f1abaf --- /dev/null +++ b/contrib/mobile/mobile_mem_go120.go @@ -0,0 +1,10 @@ +//go:build go1.20 +// +build go1.20 + +package mobile + +import "runtime/debug" + +func setMemLimitIfPossible() { + debug.SetMemoryLimit(1024 * 1024 * 40) +} diff --git a/contrib/mobile/mobile_mem_other.go b/contrib/mobile/mobile_mem_other.go new file mode 100644 index 000000000..729d9c2a5 --- /dev/null +++ b/contrib/mobile/mobile_mem_other.go @@ -0,0 +1,8 @@ +//go:build !go1.20 +// +build !go1.20 + +package mobile + +func setMemLimitIfPossible() { + // not supported by this Go version +}