mirror of
https://github.com/Simple-Tracker/qBittorrent-ClientBlocker.git
synced 2025-01-09 04:07:55 +08:00
Add impossible GC
This commit is contained in:
parent
a807248f9a
commit
75ddfcd647
29
console.go
29
console.go
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
"strings"
|
||||
"strconv"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type IPInfoStruct struct {
|
||||
@ -369,6 +370,33 @@ func Task() {
|
||||
}
|
||||
}
|
||||
}
|
||||
func GC() {
|
||||
ipMapGCCount := (len(peerMap) - 2333333)
|
||||
peerMapGCCount := (len(peerMap) - 2333333)
|
||||
|
||||
if ipMapGCCount > 0 {
|
||||
for ip, _ := range ipMap {
|
||||
ipMapGCCount--
|
||||
delete(ipMap, ip)
|
||||
if ipMapGCCount <= 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
runtime.GC()
|
||||
Log("GC", "触发垃圾回收 (ipMap)", true)
|
||||
}
|
||||
if peerMapGCCount > 0 {
|
||||
for ip, _ := range peerMap {
|
||||
peerMapGCCount--
|
||||
delete(peerMap, ip)
|
||||
if peerMapGCCount <= 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
runtime.GC()
|
||||
Log("GC", "触发垃圾回收 (peerMap)", true)
|
||||
}
|
||||
}
|
||||
func RunConsole() {
|
||||
RegFlag()
|
||||
ShowVersion()
|
||||
@ -403,5 +431,6 @@ func RunConsole() {
|
||||
currentTimestamp = time.Now().Unix()
|
||||
LoadInitConfig(false)
|
||||
Task()
|
||||
GC()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user