fix(server): release MatchResult back to pool after use
Add matcher.ReleaseMatchResult(result) in the base handler to prevent sync.Pool object leak. Every Match() call acquires from pool but the caller never returned objects, causing unbounded pool growth.
This commit is contained in:
parent
10f16bfda9
commit
2be6b67d0b
@ -529,9 +529,10 @@ func (s *Server) startSingleMode() error {
|
||||
result := locationEngine.Match(ctx.Path())
|
||||
if result != nil && result.Handler != nil {
|
||||
result.Handler(ctx)
|
||||
matcher.ReleaseMatchResult(result)
|
||||
return
|
||||
}
|
||||
// 无匹配,返回 404
|
||||
matcher.ReleaseMatchResult(result)
|
||||
ctx.SetStatusCode(404)
|
||||
ctx.SetBodyString("Not Found")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user