Hi All,

I'm running a SSL client on embedded system (VxWorks) which makes
secure connections to LDAP Server. I'm using the memory leak debugger
provided by OpenSSL.
I'm noticing that after each connection is made and disconnected, the
memory leak increases by 60 bytes and some times by 140 bytes.

++++++++++++++++++++++++++++++++++++++++++++++++++
After each connection is made, I'm closing the SSL object by using:
++++++++++++++++++++++++++++++++++++++++++++++++++
SSL_clear(p->ssl);
SSL_shutdown( p->ssl );
SSL_free( p->ssl );
ERR_clear_error();

++++++++++++++++++++++++++++++++++++++++++++++++++
Memory leak log:
++++++++++++++++++++++++++++++++++++++++++++++++++
crypto_mem_leaks: 17817 bytes leaked in 676 chunks --> for first
connection
....
....
crypto_mem_leaks: 18704 bytes leaked in 692 chunks
crypto_mem_leaks: 18761 bytes leaked in 694 chunks
....
....
crypto_mem_leaks: 19785 bytes leaked in 712 chunk
crypto_mem_leaks: 19899 bytes leaked in 716 chunks ---> After 20th
connection

Memory leak has grown from 17817 bytes to 19899 bytes for 20
connections.
I'm not sure if this is really a memory leak or this memory is being
used by the library.

After making 20 connections, I have cleaned up all the memory allocated
to SSL library by using the following calls:

SSL_CTX_free(ctx);
EVP_cleanup();
ERR_remove_state(0);
ERR_free_strings();
ENGINE_cleanup();
CRYPTO_cleanup_all_ex_data();

++++++++++++++++++++++++++++++++++++++++++++++++++
And this is the memory log after closing the context object:
++++++++++++++++++++++++++++++++++++++++++++++++++

[15:51:32] 8 file=lhash.c, line=193, thread=264258400, number=12,
address=03D74FC0

[15:51:32] 7 file=lhash.c, line=121, thread=264258400, number=64,
address=03B8B688
> thread=264258400, file=err.c, line=432, info="int_thread_get

(err.c)"

[15:56:39] 3124 file=lhash.c, line=193, thread=141514008, number=12,
address=05E5CF98

[16:33:57] 38935 file=lhash.c, line=193, thread=141277168, number=12,
address=05F68FA8

[16:13:52] 18808 file=lhash.c, line=193, thread=248312960, number=12,
address=05F74B58

[15:51:32] 6 file=lhash.c, line=119, thread=264258400, number=96,
address=03AF3520
> thread=264258400, file=err.c, line=432, info="int_thread_get

(err.c)"

[16:13:52] 18807 file=err.c, line=1013, thread=248312960, number=396,
address=08471660

[16:33:57] 38934 file=err.c, line=1013, thread=141277168, number=396,
address=08472D30

[15:51:32] 5 file=err.c, line=1013, thread=264258400, number=396,
address=03924878

[15:51:32] 9 file=err.c, line=1067, thread=264258400, number=81,
address=03AF3C28

[15:56:39] 3123 file=err.c, line=1013, thread=141514008, number=396,
address=0847C850

crypto_mem_leaks: 1873 bytes leaked in 11 chunks

Max memory (396 bytes) is being leaked by err.c, line=1013.

My Questions:

1) The memory leak increases by 60 bytes after each connection is made.
Is this really a memory leak or this memory is being used by the
library?

2) Is there anyway that I can clean up the memory leaked by err.c?

Please let me know if I'm missing nay other calls which would clean up
the memory.

Thanks in advance.