From dev-return-13585-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Sun Jan 16 15:25:22 2005
Return-Path:
Delivered-To: apmail-apr-dev-archive@www.apache.org
Received: (qmail 52933 invoked from network); 16 Jan 2005 15:25:22 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199)
by minotaur-2.apache.org with SMTP; 16 Jan 2005 15:25:22 -0000
Received: (qmail 30410 invoked by uid 500); 16 Jan 2005 15:25:21 -0000
Delivered-To: apmail-apr-dev-archive@apr.apache.org
Received: (qmail 30378 invoked by uid 500); 16 Jan 2005 15:25:21 -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 30363 invoked by uid 99); 16 Jan 2005 15:25:21 -0000
X-ASF-Spam-Status: No, hits=0.1 required=10.0
tests=FORGED_RCVD_HELO
X-Spam-Check-By: apache.org
Received-SPF: neutral (hermes.apache.org: local policy)
Received: from firstmarine.cust-gw.jnb6.alter.net (HELO gatekeeper.fma.co.za) (196.31.24.162)
by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 16 Jan 2005 07:25:20 -0800
Received: from localhost (localhost.localdomain [127.0.0.1])
by gatekeeper.fma.co.za (Postfix) with ESMTP id 8B9BC8896F;
Sun, 16 Jan 2005 17:24:49 +0200 (SAST)
Received: from gatekeeper.fma.co.za ([127.0.0.1])
by localhost (gatekeeper.fma.co.za [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 04061-01; Sun, 16 Jan 2005 17:24:45 +0200 (SAST)
Received: from [196.30.143.210] (gatekeeper.fma.co.za [196.30.143.210])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(No client certificate requested)
by gatekeeper.fma.co.za (Postfix) with ESMTP id D2DEF83B38;
Sun, 16 Jan 2005 17:24:34 +0200 (SAST)
Message-ID: <41EA8726.2060301@sharp.fm>
Date: Sun, 16 Jan 2005 17:24:22 +0200
From: Graham Leggett
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040925
X-Accept-Language: en-za, en-us, en
MIME-Version: 1.0
To: Eufordia
Cc: dev@apr.apache.org
Subject: Re: Inf. on pool...
References: <034401c4fbd5$029547c0$e6ec6f83@robinson.cam.ac.uk> <002001c4fbdc$43622960$e335de54@furbo>
In-Reply-To: <002001c4fbdc$43622960$e335de54@furbo>
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------ms030508020808040307010507"
X-Virus-Scanned: by amavisd-new at fma.co.za
X-Virus-Checked: Checked
X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N
This is a cryptographically signed message in MIME format.
--------------ms030508020808040307010507
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Eufordia wrote:
> Is there a good soul that could explain me what is exactly a "pool"?
Traditional ways of asking for memory involves:
- asking for some memory
- giving it back when you are finished
The trouble is with the second part - how are you sure you gave all the
memory back when you were finished with it? Usually no, and thus we have
memory leaks.
What if you could do this:
- ask for some memory
- ask for some more memory
- ask for even more memory
- ok I'm finished - clean up all the above in one go
If you could, you could free everything up in one go, and be sure you
didn't miss anything, and be sure again that you're not leaking memory.
APR allows you to do this by using "pools" of memory. Depending on the
task you are trying to do, you do this:
- create a pool
- allocate memory from the pool
- allocate more memory from the pool
- and more and more
- ok, I'm done - clean up the entire pool in one go
To make it more fun, when you create a pool, you can create it as a
"child" of another pool. For example, you might have a "global" pool
that all your memory is taken from. Then you create a "subtask" pool as
a child of the "global" pool to perform some task. When you're finished
doing the subtask, you clean up the subtask pool. If an error happens
and you have to exit completely, if you clean up the global pool, the
subtask pool will be cleaned up too.
The fun continues: You can get the pool cleanup to clean up more than
just memory. If you open a file, register a function to close the file
with the pool. When you clean up the pool, the file will be closed, and
you don't leak file descriptors.
APR pools make it easy and clean for code to make sure it cleans up
after itself preventing leaks.
Hope this gives you a direction to start in.
Regards,
Graham
--
--------------ms030508020808040307010507
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJGzCC
AugwggJRoAMCAQICAwyZ8DANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UE
ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv
bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0EwHhcNMDQwNjMwMTUxNjQ1WhcNMDUwNjMwMTUxNjQ1
WjBdMRAwDgYDVQQEEwdMZWdnZXR0MQ8wDQYDVQQqEwZHcmFoYW0xFzAVBgNVBAMTDkdyYWhh
bSBMZWdnZXR0MR8wHQYJKoZIhvcNAQkBFhBtaW5mcmluQHNoYXJwLmZtMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwbwE90xkX5511UvMm4pwnFvv0nIIORsm+b+7Vgf04cob
H+fQaDVSDgKfZBm4lgoKQtv/2N+jXxzKtubau6yNMYvN+7iVkQJuLIjpo4DQ2tb+hIvVsFvc
WkkFpm2+a8lIop1grh2OVIfxHfI/3OA4LbX1Ryq2qAou7TzQh6Te8KjdSigbf1l2gAyCT4ex
wLosSdHcTzv2WrYePJP107czC9gE237E68b+63Wmrc42Q4toz09XAaJnxebqSXWKhSx4h8cv
10hweAYXF5WiEUbINGoRD3V7pWRTbOBcz/oPpD8kh6kSu7iyDuchdOfIpy150ff/FCtI8h7f
LEXnBvh16wIDAQABoy0wKzAbBgNVHREEFDASgRBtaW5mcmluQHNoYXJwLmZtMAwGA1UdEwEB
/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAgTOjVmbVAi4gtKNhUI2UcMWE56z6nG7KxQZ2EmJ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