• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Introduction</title>
5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Boost.Pool">
8<link rel="up" href="../pool.html" title="Introduction and Overview">
9<link rel="prev" href="conventions.html" title="Documentation Naming and Formatting Conventions">
10<link rel="next" href="usage.html" title="How do I use Pool?">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="conventions.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../pool.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="usage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="boost_pool.pool.introduction"></a><a class="link" href="introduction.html" title="Introduction">Introduction</a>
28</h3></div></div></div>
29<h6>
30<a name="boost_pool.pool.introduction.h0"></a>
31        <span class="phrase"><a name="boost_pool.pool.introduction.what_is_pool_"></a></span><a class="link" href="introduction.html#boost_pool.pool.introduction.what_is_pool_">What
32        is Pool?</a>
33      </h6>
34<p>
35        Pool allocation is a memory allocation scheme that is very fast, but limited
36        in its usage. For more information on pool allocation (also called <span class="emphasis"><em>simple
37        segregated storage</em></span>, see <a class="link" href="pooling.html#boost_pool.pool.pooling.concepts" title="Basic ideas behind pooling">concepts</a>
38        concepts and <a class="link" href="pooling.html#boost_pool.pool.pooling.simple" title="Simple Segregated Storage">Simple Segregated
39        Storage</a>).
40      </p>
41<h6>
42<a name="boost_pool.pool.introduction.h1"></a>
43        <span class="phrase"><a name="boost_pool.pool.introduction.why_should_i_use_pool_"></a></span><a class="link" href="introduction.html#boost_pool.pool.introduction.why_should_i_use_pool_">Why
44        should I use Pool?</a>
45      </h6>
46<p>
47        Using Pools gives you more control over how memory is used in your program.
48        For example, you could have a situation where you want to allocate a bunch
49        of small objects at one point, and then reach a point in your program where
50        none of them are needed any more. Using pool interfaces, you can choose to
51        run their destructors or just drop them off into oblivion; the pool interface
52        will guarantee that there are no system memory leaks.
53      </p>
54<h6>
55<a name="boost_pool.pool.introduction.h2"></a>
56        <span class="phrase"><a name="boost_pool.pool.introduction.when_should_i_use_pool_"></a></span><a class="link" href="introduction.html#boost_pool.pool.introduction.when_should_i_use_pool_">When should
57        I use Pool?</a>
58      </h6>
59<p>
60        Pools are generally used when there is a lot of allocation and deallocation
61        of small objects. Another common usage is the situation above, where many
62        objects may be dropped out of memory.
63      </p>
64<p>
65        In general, use Pools when you need a more efficient way to do unusual memory
66        control.
67      </p>
68<h6>
69<a name="boost_pool.pool.introduction.h3"></a>
70        <span class="phrase"><a name="boost_pool.pool.introduction.which_pool_allocator_should_i_use_"></a></span><a class="link" href="introduction.html#boost_pool.pool.introduction.which_pool_allocator_should_i_use_">Which
71        pool allocator should I use?</a>
72      </h6>
73<p>
74        <code class="computeroutput"><span class="identifier">pool_allocator</span></code> is a more
75        general-purpose solution, geared towards efficiently servicing requests for
76        any number of contiguous chunks.
77      </p>
78<p>
79        <code class="computeroutput"><span class="identifier">fast_pool_allocator</span></code> is also
80        a general-purpose solution but is geared towards efficiently servicing requests
81        for one chunk at a time; it will work for contiguous chunks, but not as well
82        as pool_allocator.
83      </p>
84<p>
85        If you are seriously concerned about performance, use <code class="computeroutput"><span class="identifier">fast_pool_allocator</span></code>
86        when dealing with containers such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>,
87        and use <code class="computeroutput"><span class="identifier">pool_allocator</span></code> when
88        dealing with containers such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>.
89      </p>
90</div>
91<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
92<td align="left"></td>
93<td align="right"><div class="copyright-footer">Copyright © 2000-2006 Stephen Cleary<br>Copyright © 2011 Paul A. Bristow<p>
94        Distributed under the Boost Software License, Version 1.0. (See accompanying
95        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
96      </p>
97</div></td>
98</tr></table>
99<hr>
100<div class="spirit-nav">
101<a accesskey="p" href="conventions.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../pool.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="usage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
102</div>
103</body>
104</html>
105