Skip to content

Commit

Permalink
GC optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyHeeead committed Jan 29, 2024
1 parent 667dfa2 commit 798219b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ var redisClient redis.Conn

func main() {
gin.SetMode(gin.ReleaseMode)

// GC 优化
ballast := make([]byte, 1<<30) // 分配 1G 内存,不会实际占用物理内存,不可该读写变量
defer func() {
log.Println("ballast len %v", len(ballast))
}()

router := gin.Default()

// Log 收集中间件
Expand Down Expand Up @@ -177,7 +184,7 @@ func main() {
ballast := make([]byte, 1<<27) // 分配 128M 内存,不会实际占用物理内存,不可读写该变量

Check failure on line 184 in main.go

View workflow job for this annotation

GitHub Actions / Linux arm64 build

no new variables on left side of :=

Check failure on line 184 in main.go

View workflow job for this annotation

GitHub Actions / Windows x64 build

no new variables on left side of :=

Check failure on line 184 in main.go

View workflow job for this annotation

GitHub Actions / Linux amd64 build

no new variables on left side of :=
defer func() {
log.Println("ballast len %v", len(ballast))
}()
}()

router.Run(fmt.Sprintf(":%d", *port))
}
Expand Down

0 comments on commit 798219b

Please sign in to comment.