apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Stan <adrst...@yahoo.com>
Subject Re: apr_thread_mutex_destroy not freeing memory
Date Thu, 29 May 2008 20:36:36 GMT

The memory is allocated on a pool.
The memory is not freed manually for each object allocated on a pool. Instead, the memory
for all objects allocated on the pool is getting freed when the pool is destroyed (using apr_pool_destroy).
This is why the pools are getting used in the first place in apr, so that you don't have to
free the memory allocated for each object individually, but to destroy the pool and all the
objects allocated on it will be freed at once. 


--- On Thu, 5/29/08, Marc Mongenet &lt;marc@mongenet.ch&gt; wrote:
From: Marc Mongenet &lt;marc@mongenet.ch&gt;
Subject: apr_thread_mutex_destroy not freeing memory
To: dev@apr.apache.org
Date: Thursday, May 29, 2008, 11:09 PM


I think that apr_thread_mutex_destroy does not free the memory
allocated in apr_thread_mutex_create (on unix, and also on win32 I think).

static apr_status_t thread_mutex_cleanup(void *data)
    apr_thread_mutex_t *mutex = data;
    apr_status_t rv;

    rv = pthread_mutex_destroy(&amp;mutex-&gt;mutex);
    if (rv) {
        rv = errno;
    return rv;

APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
                                                  unsigned int flags,
                                                  apr_pool_t *pool)
/* ................... */

    new_mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
    new_mutex-&gt;pool = pool;

/* ................... */

Marc Mongenet

View raw message