Skip to content

Commit 201393f

Browse files
davidbenevanlucas
authored andcommittedNov 13, 2017
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: #16130 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent efd9bc3 commit 201393f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎src/node_crypto.h

+12
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ class SecureContext : public BaseObject {
106106
static const int kTicketKeyIVIndex = 4;
107107

108108
protected:
109+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
109110
static const int64_t kExternalSize = sizeof(SSL_CTX);
111+
#else
112+
// OpenSSL 1.1.0 has opaque structures. This is an estimate based on the size
113+
// as of OpenSSL 1.1.0f.
114+
static const int64_t kExternalSize = 872;
115+
#endif
110116

111117
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
112118
static void Init(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -220,11 +226,17 @@ class SSLWrap {
220226
protected:
221227
typedef void (*CertCb)(void* arg);
222228

229+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
223230
// Size allocated by OpenSSL: one for SSL structure, one for SSL3_STATE and
224231
// some for buffers.
225232
// NOTE: Actually it is much more than this
226233
static const int64_t kExternalSize =
227234
sizeof(SSL) + sizeof(SSL3_STATE) + 42 * 1024;
235+
#else
236+
// OpenSSL 1.1.0 has opaque structures. This is an estimate based on the size
237+
// as of OpenSSL 1.1.0f.
238+
static const int64_t kExternalSize = 4448 + 1024 + 42 * 1024;
239+
#endif
228240

229241
static void InitNPN(SecureContext* sc);
230242
static void AddMethods(Environment* env, v8::Local<v8::FunctionTemplate> t);

0 commit comments

Comments
 (0)