Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 17620 invoked from network); 4 Apr 2008 13:28:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Apr 2008 13:28:32 -0000 Received: (qmail 4361 invoked by uid 500); 4 Apr 2008 13:28:31 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 4338 invoked by uid 500); 4 Apr 2008 13:28:31 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 4329 invoked by uid 99); 4 Apr 2008 13:28:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Apr 2008 06:28:31 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cheprod@gmail.com designates 64.233.184.227 as permitted sender) Received: from [64.233.184.227] (HELO wr-out-0506.google.com) (64.233.184.227) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Apr 2008 13:27:48 +0000 Received: by wr-out-0506.google.com with SMTP id 57so53176wri.12 for ; Fri, 04 Apr 2008 06:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=OKv1MaJQPEJogSrV/G5LCGVHBFwFfOgK5HRFgV4pRdk=; b=r80nTvx9ghcLSFDTgq0eadyRKFiIQRevTP6c4g4E1ebE8n/AQdhPX45v8cDTimS9eFLR5iR8AC6R9uQhDbmGVTDSzu7Toy5DeEaj92wYzQr/IKSBe7TJRWVhuEma+ICVtyR1klBJoUMwV0B30eWo3dTMNF9c+6eL9Qx4iJ9+j/M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=uNRlXiWeTT7kTksmbEhG7/ZPPifQVrREmotb19vLWt9vdNeH+Q1Bhjrm4Yj+iCFrYLcg+6vfVpd1KN5iaADKrOIIJgtF3FxmHUhanhjWdvJP6GJeXrF+slIeGv+EuT7XpwuvfzBiZrZ5Y/mPZS1S1bDWhWxy3tZNtH5HKhahWZ4= Received: by 10.141.142.15 with SMTP id u15mr483586rvn.66.1207315679411; Fri, 04 Apr 2008 06:27:59 -0700 (PDT) Received: by 10.140.194.17 with HTTP; Fri, 4 Apr 2008 06:27:59 -0700 (PDT) Message-ID: <887839280804040627y6e09db00hc8cdeb43a71a03e6@mail.gmail.com> Date: Fri, 4 Apr 2008 15:27:59 +0200 From: Thib To: modules-dev@httpd.apache.org Subject: Re: How to manage memory allocation/free in the handler ? In-Reply-To: <1404e5910804040611q35637721v37e66232dcfcaefe@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4796_11749557.1207315679408" References: <887839280804040507v6a3c0br69888fb1d810f5cd@mail.gmail.com> <1404e5910804040611q35637721v37e66232dcfcaefe@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_4796_11749557.1207315679408 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Thanks for this response. For the new config, there is no problem because I create a new one only when my "create config method" (create_snu_config method) is called : static void *create_snu_config(apr_pool_t *p, server_rec *s) { ... newcfg = (snu_config *) apr_pcalloc(p, sizeof(snu_config)); ... } However, on the handler method (snu_handler) which is called at each time a client perform a request, I need to allocate memory. I wrote the following instruction : static int snu_handler(request_rec *r) { ... eni.calling = (char *) apr_pcalloc(r->pool, TAILL_CHAMPS * sizeof(char)); ... } My mistake was "how to free this allocated memory?". If I understand well: - The request_rec pool (r->pool) is not the same pool as the apr_pool_t "p" used in the create_snu_config method - The request_rec pool (r->pool) is free automatically at the end of the client request (end of the snu_handler pool) Thanks a lot for your help (and sorry for my english). Thib 2008/4/4, Eric Covener : > > On Fri, Apr 4, 2008 at 8:07 AM, Thib wrote: > > > For example, in create_snu_config : new_cfg = (snu_config *) > apr_pcalloc(p, > > sizeof(snu_config)); > > > > And I don't know how to free this memory at the end of the handler > method. I > > don't find any method in apr to do that (as apr_pfree...). > > > > Each pool available to you at different stages has a fixed lifetime > and is cleaned up by apache, including recliaming anything you've > allocated. You shouldn't have to manually manipulate this unless you > want it to live shorter/longer then a pool you have access to. > > Are you creating a new config too often? Normal data that only has to > live as long as a request should be allocated out of r->pool ("request > pool") > > http://www.apachetutor.org/dev/pools > > -- > Eric Covener > covener@gmail.com > ------=_Part_4796_11749557.1207315679408--