# OpenSSL memory management

**URL:** <https://www.ruby-forum.com/t/openssl-memory-management/235301>\
**Category:** NGINX\
**Created:** [June 12, 2013, 8:32am UTC](https://www.ruby-forum.com/t/openssl-memory-management/235301 "2013-06-12T08:32:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [June 12, 2013, 8:32am UTC](https://www.ruby-forum.com/t/openssl-memory-management/235301/1 "2013-06-12T08:32:33Z")

</div>

Hi,

I am new to this list and to nginx, so here is a short intro:

I am Jan A., primarily a complete REST/HTTP-head and recently  
focussing on REST API security. About to write an nginx module as an  
authenticating HTTP gateway.

I have a question regarding memory management and the use of OpenSSL  
(libcrypto) in nginx:

AFAIK, libcrypto is doing quite a lot of memory  
allocations/deallocations  
internally, unsing standard malloc etc.

When a piece software that builds upon libcrypto provides its own  
memory management (for example nginx) it can explicitly set the  
memory management functions used by libcrypto. This can be done  
by using CRYPTO\_set\_mem\_functions (#include \<crypto.h\>).

Looking at the nginx sources, I did not find any use of this feature. Am  
I missing something, or does the SSL module of nginx simply ignore  
the memory management issue, defering to the use of malloc inside  
libcrypto?

If so, can anyone explain the rationale for doiing so?

Jan

---

<div class="post-metadata">

**Author:** ![jandot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jandot](https://www.ruby-forum.com/u/jandot)\
**Post date:** [June 13, 2013, 1:42pm UTC](https://www.ruby-forum.com/t/openssl-memory-management/235301/2 "2013-06-13T13:42:05Z")

</div>

Hello!

On Wed, Jun 12, 2013 at 08:31:47AM +0200, Jan A. wrote:

> the memory management issue, defering to the use of malloc inside  
> libcrypto?
> 
> If so, can anyone explain the rationale for doiing so?

OpenSSL allocations life time often more than a request life time,  
and sometimes more than a connection life time. This makes use of  
nginx memory management functions mostly pointless.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
