Hi All,

I have a dll(called sample.dll) which links to libeay32.dll and
ssleay32.dll at compile time.
Then i load/unload this sample.dll from an .exe using LoadLibrary and
FreeLibrary. I can see a definite memory leak(shown in Task Manager)
after the FreeLibrary call.

During the DLL_PROCESS_ATTACH, I call
SSL_library_init();
SSL_load_error_strings();
During DLL_PROCESS_DETACH, I call
ERR_remove_state(0);
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
SSL_free_comp_methods(); //Added this code as a fix suggested in
another forum

The openSSL version i use is 0.9.8b(although i have tried with 0.9.7f
which also gave a memory leak)

Now, If i have an another exe which links against libeay32.dll and
ssleay32.dll at compile time.
I make the following 3 calls
SSL_library_init();
EVP_cleanup();
SSL_free_comp_methods();

And i see no memory leak.


So when loading/unloading at run-time, there is a definite memory leak
as compared to a compile-time load.

This tells me that some static data, methods etc are called which
happens during every load/unload(and thus the leak) but ofcourse would
happen only once(at .exe startup and end) in case of a compile time
load.
And this would explain the memory leak.

Can somebody confirm this behaviour and if possible, direct me to a
possible solution for this issue.

Thanks
VT