internal/debug: polish comment

This commit is contained in:
Gary Rong 2025-04-22 12:52:26 +08:00
parent c428a33ec7
commit 135623db1d

View file

@ -35,6 +35,7 @@ import (
"sync"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/hashicorp/go-bexpr"
)
@ -239,12 +240,19 @@ func (*HandlerT) SetGCPercent(v int) int {
// SetMemoryLimit sets the GOMEMLIMIT for the process. It returns the previous limit.
// Note:
//
// - The input limit is provided as bytes. A negative input does not adjust the limit
// - A zero limit or a limit that's lower than the amount of memory used by the Go runtime may cause the garbage collector to runnearly continuously. However, the application may still make progress.
//
// - A zero limit or a limit that's lower than the amount of memory used by the Go
// runtime may cause the garbage collector to run nearly continuously. However,
// the application may still make progress.
//
// - Setting the limit too low will cause Geth to become unresponsive.
// - Geth also allocates memory off-heap, particularly for fastCache and Pebble, which can be non-trivial (a few gigabytes by default).
//
// - Geth also allocates memory off-heap, particularly for fastCache and Pebble,
// which can be non-trivial (a few gigabytes by default).
func (*HandlerT) SetMemoryLimit(limit int64) int64 {
log.Info("Setting memory limit", "limit(MB)", limit/1024/1024)
log.Info("Setting memory limit", "size", common.PrettyDuration(limit))
return debug.SetMemoryLimit(limit)
}