stacktrace icon indicating copy to clipboard operation
stacktrace copied to clipboard

memory leak

Open ycyclop opened this issue 4 years ago • 2 comments

When I do a simple stacktrace there is a memory leak that I do not expect:

int main()
{
    int counter = 0;
    while (counter < 1000)
    {
        std::cout << boost::stacktrace::stacktrace();
        counter++;
    }
}

in debug the application starts with a footprint of ~40k, at the end it raises to ~440k and as you can see all it does is call the stacktrace(). In my full application I fear it has some other impact on the memory like corruption that causes the application to misbehave after ~1000 calls but I didn't manage to reproduce it in a smaller scale. The issue I encountered is eliminated when I remove this call std::cout << boost::stacktrace::stacktrace(); in my real application.

This is on a MSVC 2019 environment. toolset v142

ycyclop avatar Jun 29 '21 12:06 ycyclop

We have also found this issue on MSVC 2019 with Boost 1.72.0

correa avatar Oct 25 '21 13:10 correa

Tested with Boost 1.77.0 and the leak still happens. If BOOST_STACKTRACE_USE_WINDBG_CACHED is defined then process memory usage remains stable (and the code runs much faster).

correa avatar Oct 25 '21 14:10 correa

Fixed in 27093f24cb2ff187b179ffc561bdf0c27d7cf551 and https://github.com/boostorg/stacktrace/commit/f783534b0f22379e39597cf380f01e7199c24c29

Will update the docs soon

apolukhin avatar Feb 24 '24 18:02 apolukhin