quic-go: Memory Leak in bufferPool

Summary: After upgrading from v0.30.0 to v0.35.1, I have noticed a memory leak in my server application. The memory consumption keeps increasing and is not released unless I restart the service.

Expected Behavior: Under normal circumstances, the server should manage memory appropriately, without any memory leaks.

Actual Behavior: After upgrading to v0.35.1, I observed a continuous increase in memory usage, which is not released over time. As a result, the server becomes memory-intensive and requires a restart to free up the memory.

Environment:

Previous Version: v0.30.0
Current Version: v0.35.1
Operating System:[Linux debian 6.1.0-7-amd64
go: 1.19

pprof

File: webService.run
Build ID: 046cd5ef5de1f12c5d4b70dbb96ebafb3be85a33
Type: inuse_space
Time: Jun 3, 2023 at 4:22pm (+0330)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) web
(pprof) top
Showing nodes accounting for 388.27MB, 86.67% of 447.98MB total
Dropped 194 nodes (cum <= 2.24MB)
Showing top 10 nodes out of 116
      flat  flat%   sum%        cum   cum%
  201.79MB 45.04% 45.04%   201.79MB 45.04%  github.com/quic-go/quic-go.init.0.func1
   58.38MB 13.03% 58.08%    58.38MB 13.03%  github.com/webservice/utility.ReadHTTPDataBodyResponse
   32.08MB  7.16% 65.24%    32.08MB  7.16%  github.com/smallnest/goframe.(*lengthFieldBasedFrameConn).ReadFrame
   29.01MB  6.48% 71.71%    30.01MB  6.70%  github.com/quic-go/quic-go.newConn
   15.77MB  3.52% 75.23%    15.77MB  3.52%  regexp.(*Regexp).get
   13.22MB  2.95% 78.18%    15.36MB  3.43%  compress/flate.NewWriter
   11.50MB  2.57% 80.75%    11.50MB  2.57%  runtime.malg
   11.50MB  2.57% 83.32%    11.50MB  2.57%  golang.org/x/net/internal/socket.(*mmsghdrsPacker).prepare
    8.01MB  1.79% 85.11%     8.01MB  1.79%  runtime.allocm
       7MB  1.56% 86.67%    41.27MB  9.21%  github.com/quic-go/quic-go.(*Transport).init.func1
 

this is how i used quic:

func listenQuic(httpServer *http.Server) {
	var SupportedVersions = []quic.VersionNumber{quic.VersionDraft29, quic.Version1, quic.Version2}
	quicConf := &quic.Config{EnableDatagrams: true, Versions: SupportedVersions}

	serverQuic = http3.Server{
		Handler:         httpServer.Handler,
		Addr:            httpServer.Addr,
		QuicConfig:      quicConf,
		EnableDatagrams: true,
		MaxHeaderBytes:  httpServer.MaxHeaderBytes,
		TLSConfig:       httpServer.TLSConfig,
	}

	if err := serverQuic.ListenAndServe(); err != nil {
		log.Printf("Quic Server error: %v", err)
	}

}

you may have overlooked invoking b.Release() in some critical paths. i will conduct further investigation to analyze the memory leak issue. I will provide additional information once I have completed the investigation.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 23 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you for your suggestions. I will test the latest v0.34 release tomorrow to see if the memory leak issue persists. Regarding the tracer, I have also tested without any tracer set, including qlog, and unfortunately, the memory leak still occurs. Therefore, it appears that the issue is not specific to the tracer configuration.

I will provide an update tomorrow after testing v0.34 and share the results with you. If there are any specific logs, profiling data, or code snippets you would like me to gather during the testing, please let me know.

Thank you for your guidance.