mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-07 08:15:49 +08:00
合并多个计数器,便于统一的内存控制
This commit is contained in:
@@ -11,7 +11,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const maxItemsPerGroup = 100_000
|
||||
const maxItemsPerGroup = 60_000
|
||||
|
||||
var SharedCounter = NewCounter().WithGC()
|
||||
|
||||
type Counter struct {
|
||||
countMaps uint64
|
||||
@@ -25,11 +27,9 @@ type Counter struct {
|
||||
|
||||
// NewCounter create new counter
|
||||
func NewCounter() *Counter {
|
||||
var count = utils.SystemMemoryGB() * 2
|
||||
var count = utils.SystemMemoryGB() * 4
|
||||
if count < 8 {
|
||||
count = 8
|
||||
} else if count > 128 {
|
||||
count = 128
|
||||
}
|
||||
|
||||
var itemMaps = []map[uint64]*Item{}
|
||||
|
||||
Reference in New Issue
Block a user