Steffen Lips wrote:
Hi everybody,

we have written a server application wich uses openssl. now we found out, that memory increases rapidly. Then we found out, that there are memory leaks in openssl. so try this little program:

#include <openssl/bio.h>
#include <openssl/err.h>
#include <string.h>


void *crypto_mem_leak_cb(unsigned long order, const char *file, int line, int num_bytes, void *addr)
{
printf("Leak: Order: %7d, File: %-28s, Line: %4d, Bytes: %5d, Addr: %p\n", order, file, line, num_bytes, addr);
return addr;
}

int main()
{
 CRYPTO_malloc_debug_init();
 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);

 char buffer[] = "Test";

 BIO *bio = BIO_new_mem_buf(buffer, strlen(buffer));
 BIO_free(bio);


adding a "CRYPTO_cleanup_all_ex_data();" helps here

 ERR_free_strings();
 ERR_remove_state(0);
 CRYPTO_mem_leaks_cb(crypto_mem_leak_cb);
}

It will output something like this.

Leak: Order: 5, File: .\crypto\stack\stack.c , Line: 126, Bytes: 16, Addr: 003D4210
...
How can we avoid this? we have many certificate operations, so we often use BIOs.

I don't know what causes the memory leak in your server application
but the above example doesn't really show a memory leak openssl

Cheers,
Nils
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to