diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-08-11 00:18:13 +0300 |
---|---|---|
committer | Beth Griggs <Bethany.Griggs@uk.ibm.com> | 2019-08-15 17:20:39 +0300 |
commit | 460f896c631f1be52b0ab6c9f30e0b66f601b2a1 (patch) | |
tree | 6260e790f4e5698554f2846a5c9b7267c93b2568 /src | |
parent | f4242e24f9f4fb185909f040cbd2dd889d79439b (diff) |
http2: shrink default `vector::reserve()` allocations
Allocating memory upfront comes with overhead, and in particular,
`std::vector` implementations do not necessarily return memory
to the system when one might expect that (e.g. after shrinking the
vector).
Backport-PR-URL: https://github.com/nodejs/node/pull/29123
PR-URL: https://github.com/nodejs/node/pull/29122
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_http2.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc index 7d10eaf8017..e03366dd1a0 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -632,7 +632,7 @@ Http2Session::Http2Session(Environment* env, // fails. CHECK_EQ(fn(&session_, callbacks, this, *opts, *allocator_info), 0); - outgoing_storage_.reserve(4096); + outgoing_storage_.reserve(1024); outgoing_buffers_.reserve(32); { @@ -1947,7 +1947,7 @@ Http2Stream::Http2Stream(Http2Session* session, if (max_header_pairs_ == 0) { max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS; } - current_headers_.reserve(max_header_pairs_); + current_headers_.reserve(std::min(max_header_pairs_, 12u)); // Limit the number of header octets max_header_length_ = |