From 5d94712b859339d48b3eb2d3bdd00d04d66f6160 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 15 Sep 2017 20:09:43 -0400 Subject: 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 Reviewed-By: Rod Vagg --- src/node_crypto.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/node_crypto.h') 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& args); static void Init(const v8::FunctionCallbackInfo& 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 t); -- cgit v1.2.3