Hi,

Our library uses OpenSSL(v  0.9.8k) in multithreaded environment. Recently I
observed memory leak resulting from not calling ERR_remove_state().
After reading the documentation of this function, I see that
ERR_remove_state should be called when a thread exits. Since we are using
OpenSSL within a library, we can't determine when a thread is going to exit.


I am able to think about the following approaches :

1. Keep a record a threads which are spawned. when the library is unloaded
call ERR_remove_state() for every thread. This approach has the drawback of
taking too much memory for error queues of openssl, since the library may
not ever get unloaded.

2. Expose a function from our library for cleanup when the thread exits.
This approach has the drawback of changing the API. In certain scenarios it
may be hard to find out when a thread exits.

Is there any other way to avoid the memory leak caused by error queues ?

Pankaj

Reply via email to