[botan-devel] Memory Leaks with Botan 1.10.5 Amalgamation (via Botan Sqlite3)

Jack Lloyd lloyd at randombit.net
Sat Nov 16 07:00:34 EST 2013


On Fri, Nov 15, 2013 at 10:45:13AM -0800, Cory Trese wrote:

> It is also reporting a lot of memory leaks in Botan. I am hopeful that
> there is a solution -- perhaps there is a "Botan Cleanup" call I am unaware
> of?

Hi Cory,

LibraryInitializer::deinitialize (or ~LibraryInitializer) will clean up memory
allocated internally by the library.

There are not any memory leaks I'm aware of in the library, defining memory leak
as allocating memory and then losing track of it so we can't free it later. The
code does allocate quite a bit of memory at startup and hold it until shudown,
though.

Two of the traces appear that the reurn of get_pbkdf is not being deleted - if
this is the case it is actually a leak as those pointers are owned by the
caller.

The other two, related to Pooling_Allocator and a map<string,string>, are both
part of the global state which is cleaned up by the shutdown function.

From one of the tracebacks I can see that Library_State is being allocated as a
side effect of another operation, instead of via the LibraryInitializer RAII
wrapper - this is a supported option but means that no cleanup occurs unless you
explicitly call Library_State::deinitialize. So likely the fix to many of the
leak reports is a simple

Botan::LibraryInitializer botan_init;

in your main function.

Cheers,
  Jack


More information about the botan-devel mailing list