diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-06-15 01:52:35 +0300 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-06-25 08:54:49 +0300 |
commit | 15c627f185608951775f48a2e2d9b2cb2fe0ce3c (patch) | |
tree | 0f6b3dbc152f5f5bc673c669de40c4af5ff4796c /src/util-inl.h | |
parent | bfcf5b01bb4112b833a936a8266879b58ed391db (diff) |
http2: track memory allocated by nghttp2
Provide a custom memory allocator for nghttp2, and track
memory allocated by the library with it.
This makes the used-memory-per-session estimate more
accurate, and allows us to track memory leaks either
in nghttp2 itself or, more likely, through faulty
usage on our end.
It also allows us to make the per-session memory limit
more accurate in the future; currently, we are not
handling this in an ideal way, and instead let nghttp2
allocate what it wants, even if that goes over our limit.
PR-URL: https://github.com/nodejs/node/pull/21374
Refs: https://github.com/nodejs/node/pull/21373
Refs: https://github.com/nodejs/node/pull/21336
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/util-inl.h')
-rw-r--r-- | src/util-inl.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util-inl.h b/src/util-inl.h index 90c7447f7e1..c6cd263aa27 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -320,8 +320,9 @@ bool StringEqualNoCaseN(const char* a, const char* b, size_t length) { return true; } -inline size_t MultiplyWithOverflowCheck(size_t a, size_t b) { - size_t ret = a * b; +template <typename T> +inline T MultiplyWithOverflowCheck(T a, T b) { + auto ret = a * b; if (a != 0) CHECK_EQ(b, ret / a); |