Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 29483 invoked from network); 5 Sep 2003 04:33:40 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 5 Sep 2003 04:33:40 -0000 Received: (qmail 55483 invoked by uid 500); 5 Sep 2003 04:33:16 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 55361 invoked by uid 500); 5 Sep 2003 04:33:15 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 55341 invoked from network); 5 Sep 2003 04:33:14 -0000 Date: Fri, 5 Sep 2003 00:32:57 -0400 (EDT) From: Cliff Woolley X-X-Sender: jcw5q@cobra.cs.Virginia.EDU To: Chris Fallin cc: dev@apr.apache.org Subject: Re: Problem avoiding memory leak with thread creation In-Reply-To: <3F5810A3.9080208@cfallin.org> Message-ID: References: <3F5810A3.9080208@cfallin.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Thu, 4 Sep 2003, Chris Fallin wrote: > In order to prevent leaks each thread gets its own subpool, which it > frees on exit. However, I see in apr_thread_create (at > threadproc/unix/thread.c:160) that a subpool is allocated from the pool > passed to the function. This pool is the one that is destroyed in > apr_thread_exit at line 192. Thus, the pool passed in to > apr_thread_create is never freed unless done manually after > apr_thread_exit destroys the child pool, which is hard because it exits > the thread. As for whether what you described is a bug or not, I'm not sure, but you might be able to get around it one way or the other by calling apr_allocator_create() yourself, then apr_pool_create_ex() -- that way your subpool has its own block of memory that you can destroy after the thread is done, rather than having it go back into the parent pool's allocator. (apr_allocator_max_free_set() might also be useful.) Hope this helps. No doubt one of the pool wizards will jump in with other suggestions... --Cliff