mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-01 14:18:36 +00:00
Fix oom-killer JSON cache cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//go:build badlinkname
|
||||
//go:build badlinkname && !goexperiment.jsonv2
|
||||
|
||||
package oomkiller
|
||||
|
||||
@@ -7,13 +7,21 @@ import (
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
//go:linkname jsonFieldCache json.fieldCache
|
||||
//go:linkname jsonEncoderCache encoding/json.encoderCache
|
||||
var jsonEncoderCache sync.Map
|
||||
|
||||
//go:linkname jsonFieldCache encoding/json.fieldCache
|
||||
var jsonFieldCache sync.Map
|
||||
|
||||
//go:linkname contextJSONEncoderCache github.com/sagernet/sing/common/json/internal/contextjson.encoderCache
|
||||
var contextJSONEncoderCache sync.Map
|
||||
|
||||
//go:linkname contextJSONFieldCache github.com/sagernet/sing/common/json/internal/contextjson.fieldCache
|
||||
var contextJSONFieldCache sync.Map
|
||||
|
||||
func badCleanup() {
|
||||
jsonEncoderCache.Clear()
|
||||
jsonFieldCache.Clear()
|
||||
contextJSONEncoderCache.Clear()
|
||||
contextJSONFieldCache.Clear()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//go:build badlinkname && goexperiment.jsonv2
|
||||
|
||||
package oomkiller
|
||||
|
||||
import (
|
||||
"sync"
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
//go:linkname jsonArshalerCache encoding/json/v2.lookupArshalerCache
|
||||
var jsonArshalerCache sync.Map
|
||||
|
||||
//go:linkname contextJSONEncoderCache github.com/sagernet/sing/common/json/internal/contextjson.encoderCache
|
||||
var contextJSONEncoderCache sync.Map
|
||||
|
||||
//go:linkname contextJSONFieldCache github.com/sagernet/sing/common/json/internal/contextjson.fieldCache
|
||||
var contextJSONFieldCache sync.Map
|
||||
|
||||
func badCleanup() {
|
||||
jsonArshalerCache.Clear()
|
||||
contextJSONEncoderCache.Clear()
|
||||
contextJSONFieldCache.Clear()
|
||||
}
|
||||
Reference in New Issue
Block a user