mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-13 00:40:24 +03:00
Only set mobile memory limit on supported Go versions
This commit is contained in:
parent
12a3a8c73b
commit
c8b9aaeb67
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime/debug"
|
|
||||||
|
|
||||||
"github.com/gologme/log"
|
"github.com/gologme/log"
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ func (m *Yggdrasil) StartAutoconfigure() error {
|
|||||||
// StartJSON starts a node with the given JSON config. You can get JSON config
|
// StartJSON starts a node with the given JSON config. You can get JSON config
|
||||||
// (rather than HJSON) by using the GenerateConfigJSON() function
|
// (rather than HJSON) by using the GenerateConfigJSON() function
|
||||||
func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
||||||
debug.SetMemoryLimit(1024 * 1024 * 40)
|
setMemLimitIfPossible()
|
||||||
|
|
||||||
m.logger = log.New(m.log, "", 0)
|
m.logger = log.New(m.log, "", 0)
|
||||||
m.logger.EnableLevel("error")
|
m.logger.EnableLevel("error")
|
||||||
|
10
contrib/mobile/mobile_mem_go120.go
Normal file
10
contrib/mobile/mobile_mem_go120.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//go:build go1.20
|
||||||
|
// +build go1.20
|
||||||
|
|
||||||
|
package mobile
|
||||||
|
|
||||||
|
import "runtime/debug"
|
||||||
|
|
||||||
|
func setMemLimitIfPossible() {
|
||||||
|
debug.SetMemoryLimit(1024 * 1024 * 40)
|
||||||
|
}
|
8
contrib/mobile/mobile_mem_other.go
Normal file
8
contrib/mobile/mobile_mem_other.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build !go1.20
|
||||||
|
// +build !go1.20
|
||||||
|
|
||||||
|
package mobile
|
||||||
|
|
||||||
|
func setMemLimitIfPossible() {
|
||||||
|
// not supported by this Go version
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user