Skip to content

Commit 201393f

Browse files
davidbenevanlucas
authored andcommitted
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

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/node_crypto.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ class SecureContext : public BaseObject {
106106
staticconstintkTicketKeyIVIndex = 4;
107107

108108
protected:
109+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
109110
staticconstint64_tkExternalSize = 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+
staticconstint64_tkExternalSize = 872;
115+
#endif
110116

111117
staticvoidNew(const v8::FunctionCallbackInfo<v8::Value>& args);
112118
staticvoidInit(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -220,11 +226,17 @@ class SSLWrap {
220226
protected:
221227
typedefvoid (*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
staticconstint64_tkExternalSize =
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+
staticconstint64_tkExternalSize = 4448 + 1024 + 42 * 1024;
239+
#endif
228240

229241
staticvoidInitNPN(SecureContext* sc);
230242
staticvoidAddMethods(Environment* env, v8::Local<v8::FunctionTemplate> t);

0 commit comments

Comments
 (0)