apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rohan Nandode <rnand...@yahoo.com>
Subject Re: detecting apr memory leaks on windows
Date Mon, 02 Feb 2004 12:36:07 GMT

When you initialize APR library, a global pool is
created for APR library. This pool is a parent of all
pools that you create without specifying any parent
pool, as you have done below. All such pools share a
common allocator from which they allocate the required

This allocator is destroyed and freed during
apr_terminate. (or you can call apr_pool_terminate())

Hence you are seeing the memory leak when you comment
out apr_terminate().
For pools for which you have specified the parent,
their memory will be freed when the parent pool is


--- Stephen Ince <since@opendemand.com> wrote:
> When does the real memory from a pool actually get
> destroyed. I am using VC++ 6.0 to try and debug
> memory leaks. I thought that apr_pool_destroy
> destroys the real memory. If I uncomment the line
> apr_terminate(), all the memory is cleaned up. How
> can I immediately destroy the real memory from a top
> level pool?
> I have the following code:
> int main(int argc, char** argv)
> {
>     apr_pool_t *local_pool;
>     apr_initialize();
>     apr_pool_create(&local_pool, NULL);
>     apr_pool_destroy(local_pool);
> // apr_terminate();
> #if defined(_DEBUG) && defined(WIN32) 
>    OutputHeading( "Examine outstanding allocations
> (dump memory leaks)" );
>    _CrtDumpMemoryLeaks( );
>    OutputHeading( "Program exits without freeing a
> memory block" );
> #endif
>     return EXIT_SUCCESS;
> }
> Steve

Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

View raw message