/usr/share/doc/libucommon-dev/a00081.html is in libucommon-doc 3.2.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>UCommon: ucc::mempager Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="classes.html"><span>Data Structure Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Data Fields</span></a></li>
</ul>
</div>
<div class="navpath"><a class="el" href="a00214.html">ucc</a>::<a class="el" href="a00081.html">mempager</a>
</div>
</div>
<div class="contents">
<h1>ucc::mempager Class Reference</h1><!-- doxytag: class="ucc::mempager" --><!-- doxytag: inherits="ucc::memalloc" -->
<p>A managed private heap for small allocations.
<a href="#_details">More...</a></p>
<p><code>#include <<a class="el" href="a00197_source.html">memory.h</a>></code></p>
<div class="dynheader">
Inheritance diagram for ucc::mempager:</div>
<div class="dynsection">
<div class="center"><img src="a00439.png" border="0" usemap="#ucc_1_1mempager_inherit__map" alt="Inheritance graph"/></div>
<map name="ucc_1_1mempager_inherit__map" id="ucc_1_1mempager_inherit__map">
<area shape="rect" id="node5" href="a00059.html" title="A class to hold memory pointers referenced by string names." alt="" coords="63,160,172,189"/><area shape="rect" id="node9" href="a00065.html" title="A templated class for a hash pager." alt="" coords="196,160,361,189"/><area shape="rect" id="node11" href="a00142.html" title="A utility class for generic shell operations." alt="" coords="385,160,465,189"/><area shape="rect" id="node2" href="a00080.html" title="An alternate memory pager private heap manager." alt="" coords="221,5,336,35"/><area shape="rect" id="node7" href="a00019.html" title="A typed template for using a key association with typed objects." alt="" coords="5,237,229,267"/></map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for ucc::mempager:</div>
<div class="dynsection">
<div class="center"><img src="a00440.png" border="0" usemap="#ucc_1_1mempager_coll__map" alt="Collaboration graph"/></div>
<map name="ucc_1_1mempager_coll__map" id="ucc_1_1mempager_coll__map">
<area shape="rect" id="node2" href="a00080.html" title="An alternate memory pager private heap manager." alt="" coords="9,5,124,35"/></map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a17e3fb857ffb0ab3cf51eba123636071">alloc</a> (size_t size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Allocate memory from the pager heap. <a href="#a17e3fb857ffb0ab3cf51eba123636071"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a23ad5b0c723877671a4dcb63ef79d486">dealloc</a> (void *memory)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return memory back to pager heap. <a href="#a23ad5b0c723877671a4dcb63ef79d486"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#abcdb91d05edcfcd878902b6ab28af444">dup</a> (void *memory, size_t size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Duplicate existing memory block into allocated memory. <a href="#abcdb91d05edcfcd878902b6ab28af444"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a7fa56e7c899d9e471a42512d670f866e">dup</a> (const char *<a class="el" href="a00157.html">string</a>)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Duplicate NULL terminated string into allocated memory. <a href="#a7fa56e7c899d9e471a42512d670f866e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a31551310883b634bdad4fc37ed9eaa92">lock</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Lock the memory pager mutex. <a href="#a31551310883b634bdad4fc37ed9eaa92"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a12ae7c1bb279dffe55e2f37224461b70">mempager</a> (size_t page=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a memory pager. <a href="#a12ae7c1bb279dffe55e2f37224461b70"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afdc290a1fd291de22503325a498a9b5a"></a><!-- doxytag: member="ucc::mempager::purge" ref="afdc290a1fd291de22503325a498a9b5a" args="(void)" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#afdc290a1fd291de22503325a498a9b5a">purge</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Purge all allocated memory and heap pages immediately. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a87d2cc2e145455b5e17b1d1def27e90a"></a><!-- doxytag: member="ucc::mempager::unlock" ref="a87d2cc2e145455b5e17b1d1def27e90a" args="(void)" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a87d2cc2e145455b5e17b1d1def27e90a">unlock</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Unlock the memory pager mutex. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#ad8df15dd4848802c7dd79f8a81719f88">utilization</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Determine fragmentation level of acquired heap pages. <a href="#ad8df15dd4848802c7dd79f8a81719f88"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#ab2115ea0eed89545c8fd70e1b3fd2aad">zalloc</a> (size_t size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Allocate memory from the pager heap. <a href="#ab2115ea0eed89545c8fd70e1b3fd2aad"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html#a89cd453fe84b5126f6fe9849b57fbf8f">~mempager</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destroy a memory pager. <a href="#a89cd453fe84b5126f6fe9849b57fbf8f"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>A managed private heap for small allocations. </p>
<p>This is used to allocate a large number of small objects from a paged heap as needed and to then release them together all at once. This pattern has significiently less overhead than using malloc and offers less locking contention since the memory pager can also have it's own mutex. Pager pool allocated memory is always aligned to the optimal data size for the cpu bus and pages are themselves created from memory aligned allocations. A page size for a memory pager should be some multiple of the OS paging size.</p>
<p>The mempager uses a strategy of allocating fixed size pages as needed from the real heap and allocating objects from these pages as needed. A new page is allocated from the real heap when there is insufficient space in the existing page to complete a request. The largest single memory allocation one can make is restricted by the page size used, and it is best to allocate objects a significent fraction smaller than the page size, as fragmentation occurs at the end of pages when there is insufficent space in the current page to complete a request. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@gnutelephony.org">dyfet@gnutelephony.org</a>> </dd></dl>
<p>Definition at line <a class="el" href="a00197_source.html#l00183">183</a> of file <a class="el" href="a00197_source.html">memory.h</a>.</p>
<hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="a12ae7c1bb279dffe55e2f37224461b70"></a><!-- doxytag: member="ucc::mempager::mempager" ref="a12ae7c1bb279dffe55e2f37224461b70" args="(size_t page=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ucc::mempager::mempager </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>page</em> = <code>0</code></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Construct a memory pager. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>page</em> </td><td>size to use or 0 for OS allocation size. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a89cd453fe84b5126f6fe9849b57fbf8f"></a><!-- doxytag: member="ucc::mempager::~mempager" ref="a89cd453fe84b5126f6fe9849b57fbf8f" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual ucc::mempager::~mempager </td>
<td>(</td>
<td class="paramname"></td>
<td> ) </td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Destroy a memory pager. </p>
<p>Release all pages back to the heap at once. </p>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a17e3fb857ffb0ab3cf51eba123636071"></a><!-- doxytag: member="ucc::mempager::alloc" ref="a17e3fb857ffb0ab3cf51eba123636071" args="(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* ucc::mempager::alloc </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em></td>
<td> ) </td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Allocate memory from the pager heap. </p>
<p>The size of the request must be less than the size of the memory page used. The memory pager mutex is locked during this operation and then released. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>of memory request. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>allocated memory or NULL if not possible. </dd></dl>
<p>Reimplemented from <a class="el" href="a00080.html#a086ccd141c4e5d57d91c50eb27923612">ucc::memalloc</a>.</p>
</div>
</div>
<a class="anchor" id="a23ad5b0c723877671a4dcb63ef79d486"></a><!-- doxytag: member="ucc::mempager::dealloc" ref="a23ad5b0c723877671a4dcb63ef79d486" args="(void *memory)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual void ucc::mempager::dealloc </td>
<td>(</td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>memory</em></td>
<td> ) </td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return memory back to pager heap. </p>
<p>This actually does nothing, but might be used in a derived class to create a memory heap that can also receive (free) memory allocated from our heap and reuse it, for example in a full private malloc implimentation in a derived class. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>memory</em> </td><td>to free back to private heap. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="abcdb91d05edcfcd878902b6ab28af444"></a><!-- doxytag: member="ucc::mempager::dup" ref="abcdb91d05edcfcd878902b6ab28af444" args="(void *memory, size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* ucc::mempager::dup </td>
<td>(</td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>memory</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Duplicate existing memory block into allocated memory. </p>
<p>The mutex lock is acquired to perform this operation and then released. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>memory</em> </td><td>to data copy from. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>of memory to allocate. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>allocated memory with copy or NULL if cannot allocate. </dd></dl>
<p>Reimplemented from <a class="el" href="a00080.html#abe5ef90bf1698a890377c6541a6bbb1c">ucc::memalloc</a>.</p>
</div>
</div>
<a class="anchor" id="a7fa56e7c899d9e471a42512d670f866e"></a><!-- doxytag: member="ucc::mempager::dup" ref="a7fa56e7c899d9e471a42512d670f866e" args="(const char *string)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char* ucc::mempager::dup </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>string</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Duplicate NULL terminated string into allocated memory. </p>
<p>The mutex lock is acquired to perform this operation and then released. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>string</em> </td><td>to copy into memory. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>allocated memory with copy of string or NULL if cannot allocate. </dd></dl>
<p>Reimplemented from <a class="el" href="a00080.html#a0790234f08af30a0da6430552fbcdc1d">ucc::memalloc</a>.</p>
</div>
</div>
<a class="anchor" id="a31551310883b634bdad4fc37ed9eaa92"></a><!-- doxytag: member="ucc::mempager::lock" ref="a31551310883b634bdad4fc37ed9eaa92" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ucc::mempager::lock </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Lock the memory pager mutex. </p>
<p>It will be more efficient to lock the pager and then call the locked allocator than using alloc which seperately locks and unlocks for each request when a large number of allocation requests are being batched together. </p>
<p>Definition at line <a class="el" href="a00197_source.html#l00206">206</a> of file <a class="el" href="a00197_source.html">memory.h</a>.</p>
</div>
</div>
<a class="anchor" id="ad8df15dd4848802c7dd79f8a81719f88"></a><!-- doxytag: member="ucc::mempager::utilization" ref="ad8df15dd4848802c7dd79f8a81719f88" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned ucc::mempager::utilization </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Determine fragmentation level of acquired heap pages. </p>
<p>This is represented as an average % utilization (0-100) and represents the used portion of each allocated heap page vs the page size. Since requests that cannot fit on an already allocated page are moved into a new page, there is some unusable space left over at the end of the page. When utilization approaches 100, this is good. A low utilization may suggest a larger page size should be used. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>pager utilization. </dd></dl>
<p>Reimplemented from <a class="el" href="a00080.html#afe93dc2c37b8f03255e6b71e5bfd6e15">ucc::memalloc</a>.</p>
<p>Reimplemented in <a class="el" href="a00019.html#af3c27c6db90fa61408f11faf7c062cb7">ucc::assoc_pointer< T, I, M, P ></a>.</p>
</div>
</div>
<a class="anchor" id="ab2115ea0eed89545c8fd70e1b3fd2aad"></a><!-- doxytag: member="ucc::mempager::zalloc" ref="ab2115ea0eed89545c8fd70e1b3fd2aad" args="(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* ucc::mempager::zalloc </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Allocate memory from the pager heap. </p>
<p>The size of the request must be less than the size of the memory page used. The memory pager mutex is locked during this operation and then released. This version zeros memory after the mutex lock has been released. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>of memory request. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>allocated memory or NULL if not possible. </dd></dl>
<p>Reimplemented from <a class="el" href="a00080.html#a4d46bf82a4c340d10a6e96333e0c9b8b">ucc::memalloc</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>ucommon/<a class="el" href="a00197_source.html">memory.h</a></li>
</ul>
</div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:34 2010 for UCommon by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|