opt in to frame reuse on the framer to reduce garbage (#1096)

This commit is contained in:
apolcyn
2017-04-10 15:44:10 -07:00
committed by GitHub
parent bfa5dd27dc
commit ff17eeb5f6

View File

@ -383,6 +383,9 @@ func newFramer(conn net.Conn) *framer {
writer: bufio.NewWriterSize(conn, http2IOBufSize),
}
f.fr = http2.NewFramer(f.writer, f.reader)
// Opt-in to Frame reuse API on framer to reduce garbage.
// Frames aren't safe to read from after a subsequent call to ReadFrame.
f.fr.SetReuseFrames()
f.fr.ReadMetaHeaders = hpack.NewDecoder(http2InitHeaderTableSize, nil)
return f
}