@@ -64,6 +64,7 @@ class SecureContext : public BaseObject { |
64 | 64 | static const int kMaxSessionSize = 10 * 1024; |
65 | 65 |
|
66 | 66 | protected: |
| 67 | + static const int64_t kExternalSize = sizeof(SSL_CTX); |
67 | 68 |
|
68 | 69 | static void New(const v8::FunctionCallbackInfo<v8::Value>& args); |
69 | 70 | static void Init(const v8::FunctionCallbackInfo<v8::Value>& args); |
@@ -97,10 +98,12 @@ class SecureContext : public BaseObject { |
97 | 98 | cert_(nullptr), |
98 | 99 | issuer_(nullptr) { |
99 | 100 | MakeWeak<SecureContext>(this); |
| 101 | + env->isolate()->AdjustAmountOfExternalAllocatedMemory(kExternalSize); |
100 | 102 | } |
101 | 103 |
|
102 | 104 | void FreeCTXMem() { |
103 | 105 | if (ctx_) { |
| 106 | + env()->isolate()->AdjustAmountOfExternalAllocatedMemory(-kExternalSize); |
104 | 107 | if (ctx_->cert_store == root_cert_store) { |
105 | 108 | // SSL_CTX_free() will attempt to free the cert_store as well. |
106 | 109 | // Since we want our root_cert_store to stay around forever |
@@ -140,6 +143,7 @@ class SSLWrap { |
140 | 143 | session_callbacks_(false), |
141 | 144 | new_session_wait_(false) { |
142 | 145 | ssl_ = SSL_new(sc->ctx_); |
| 146 | + env_->isolate()->AdjustAmountOfExternalAllocatedMemory(kExternalSize); |
143 | 147 | CHECK_NE(ssl_, nullptr); |
144 | 148 | } |
145 | 149 |
|
@@ -166,6 +170,12 @@ class SSLWrap { |
166 | 170 | inline bool is_waiting_new_session() const { return new_session_wait_; } |
167 | 171 |
|
168 | 172 | protected: |
| 173 | + // Size allocated by OpenSSL: one for SSL structure, one for SSL3_STATE and |
| 174 | + // some for buffers. |
| 175 | + // NOTE: Actually it is much more than this |
| 176 | + static const int64_t kExternalSize = |
| 177 | + sizeof(SSL) + sizeof(SSL3_STATE) + 42 * 1024; |
| 178 | + |
169 | 179 | static void InitNPN(SecureContext* sc); |
170 | 180 | static void AddMethods(Environment* env, v8::Handle<v8::FunctionTemplate> t); |
171 | 181 |
|
|