Skip to content

Commit 84f6caa

Browse files
committed
fix: close idle conns for HTTPClient2
to prevent memory leak The HTTPClient2 instance was being created on every `NewClient()` call but its idle connections were never closed, leading to memory accumulation. While HTTPClient2 is only used as a fallback for HTTP/2 protocol errors, it still allocates ~45MB of per client instance (24MB for the client + 21MB for HTTP/2 transport config). This commit make sure that when `KillIdleConn` is enabled, both `HTTPClient` and `HTTPClient2` have their idle connections properly closed, preventing the memory leak in scenarios where multiple client instances are created. Fixes #482. Signed-off-by: Dwi Siswanto <[email protected]>
1 parent a50c5a8 commit 84f6caa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

do.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func (c *Client) closeIdleConnections() {
151151
} else {
152152
c.requestCounter.Store(0)
153153
c.HTTPClient.CloseIdleConnections()
154+
c.HTTPClient2.CloseIdleConnections()
154155
}
155156
}
156157
}

0 commit comments

Comments
 (0)