mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Refactor: Optimize Memory Usage At Startup
https://github.com/XTLS/Xray-core/issues/68#issuecomment-745231528
This commit is contained in:
parent
2e942e0303
commit
45f44c401a
2 changed files with 101 additions and 30 deletions
|
@ -9,12 +9,14 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/xtls/xray-core/common/cmdarg"
|
||||
"github.com/xtls/xray-core/common/platform"
|
||||
"github.com/xtls/xray-core/core"
|
||||
"github.com/xtls/xray-core/infra/conf"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
)
|
||||
|
||||
|
@ -78,8 +80,13 @@ func executeRun(cmd *base.Command, args []string) {
|
|||
}
|
||||
defer server.Close()
|
||||
|
||||
conf.FileCache = nil
|
||||
conf.IPCache = nil
|
||||
conf.SiteCache = nil
|
||||
|
||||
// Explicitly triggering GC to remove garbage from config loading.
|
||||
runtime.GC()
|
||||
debug.FreeOSMemory()
|
||||
|
||||
{
|
||||
osSignals := make(chan os.Signal, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue