diff options
author | David Benjamin <davidben@google.com> | 2017-09-15 20:09:43 -0400 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2017-11-11 20:42:49 +1100 |
commit | 5d94712b859339d48b3eb2d3bdd00d04d66f6160 (patch) | |
tree | b1cb99eba2ce75ece7d4c9785e630f1772d092bf /src/node_crypto.h | |
parent | 9f91427ad66fef08b2dcd872c9052221c8cdf8f5 (diff) | |
download | android-node-v8-5d94712b859339d48b3eb2d3bdd00d04d66f6160.tar.gz android-node-v8-5d94712b859339d48b3eb2d3bdd00d04d66f6160.tar.bz2 android-node-v8-5d94712b859339d48b3eb2d3bdd00d04d66f6160.zip |
crypto: estimate kExternalSize
Based on a build of OpenSSL 1.1.0f.
The exact sizes are not particularly important (the original value was
missing all the objects hanging off anyway), only that V8 garbage
collector be aware that there is some memory usage beyond the sockets
themselves.
PR-URL: https://github.com/nodejs/node/pull/16130
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'src/node_crypto.h')
-rw-r--r-- | src/node_crypto.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h index a155411aa8..235736dde6 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -106,7 +106,13 @@ class SecureContext : public BaseObject { static const int kTicketKeyIVIndex = 4; protected: +#if OPENSSL_VERSION_NUMBER < 0x10100000L static const int64_t kExternalSize = sizeof(SSL_CTX); +#else + // OpenSSL 1.1.0 has opaque structures. This is an estimate based on the size + // as of OpenSSL 1.1.0f. + static const int64_t kExternalSize = 872; +#endif static void New(const v8::FunctionCallbackInfo<v8::Value>& args); static void Init(const v8::FunctionCallbackInfo<v8::Value>& args); @@ -220,11 +226,17 @@ class SSLWrap { protected: typedef void (*CertCb)(void* arg); +#if OPENSSL_VERSION_NUMBER < 0x10100000L // Size allocated by OpenSSL: one for SSL structure, one for SSL3_STATE and // some for buffers. // NOTE: Actually it is much more than this static const int64_t kExternalSize = sizeof(SSL) + sizeof(SSL3_STATE) + 42 * 1024; +#else + // OpenSSL 1.1.0 has opaque structures. This is an estimate based on the size + // as of OpenSSL 1.1.0f. + static const int64_t kExternalSize = 4448 + 1024 + 42 * 1024; +#endif static void InitNPN(SecureContext* sc); static void AddMethods(Environment* env, v8::Local<v8::FunctionTemplate> t); |