diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-02-17 17:25:57 +0000 |
|---|---|---|
| committer | <> | 2015-03-17 16:26:24 +0000 |
| commit | 780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch) | |
| tree | 598f8b9fa431b228d29897e798de4ac0c1d3d970 /docs/programmer_reference/stl_memory_mgmt.html | |
| parent | 7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff) | |
| download | berkeleydb-master.tar.gz | |
Diffstat (limited to 'docs/programmer_reference/stl_memory_mgmt.html')
| -rw-r--r-- | docs/programmer_reference/stl_memory_mgmt.html | 199 |
1 files changed, 123 insertions, 76 deletions
diff --git a/docs/programmer_reference/stl_memory_mgmt.html b/docs/programmer_reference/stl_memory_mgmt.html index a32bbef5..f82eba9f 100644 --- a/docs/programmer_reference/stl_memory_mgmt.html +++ b/docs/programmer_reference/stl_memory_mgmt.html @@ -14,7 +14,7 @@ <body> <div xmlns="" class="navheader"> <div class="libver"> - <p>Library Version 11.2.5.3</p> + <p>Library Version 12.1.6.1</p> </div> <table width="100%" summary="Navigation header"> <tr> @@ -40,12 +40,12 @@ <dl> <dt> <span class="sect2"> - <a href="stl_memory_mgmt.html#idp1384984">Freeing memory</a> + <a href="stl_memory_mgmt.html#idp952296">Freeing memory</a> </span> </dt> <dt> <span class="sect2"> - <a href="stl_memory_mgmt.html#idp1389512">Type specific notes</a> + <a href="stl_memory_mgmt.html#idp994336">Type specific notes</a> </span> </dt> </dl> @@ -54,25 +54,27 @@ <div class="titlepage"> <div> <div> - <h3 class="title"><a id="idp1384984"></a>Freeing memory</h3> + <h3 class="title"><a id="idp952296"></a>Freeing memory</h3> </div> </div> </div> - <p> - When using dbstl, make sure memory allocated in the heap is - released after use. The rules for this are: - </p> + <p> + When using dbstl, make sure memory allocated in the + heap is released after use. The rules for this are: + </p> <div class="itemizedlist"> <ul type="disc"> <li> - <p> - dbstl will free/delete any memory allocated by dbstl itself. - </p> + <p> + dbstl will free/delete any memory allocated by + dbstl itself. + </p> </li> <li> <p> - You are responsible for freeing/deleting any memory allocated by your code outside of dbstl. - </p> + You are responsible for freeing/deleting any + memory allocated by your code outside of dbstl. + </p> </li> </ul> </div> @@ -81,7 +83,7 @@ <div class="titlepage"> <div> <div> - <h3 class="title"><a id="idp1389512"></a>Type specific notes</h3> + <h3 class="title"><a id="idp994336"></a>Type specific notes</h3> </div> </div> </div> @@ -89,82 +91,126 @@ <div class="titlepage"> <div> <div> - <h4 class="title"><a id="idp1425304"></a>DbEnv/Db</h4> + <h4 class="title"><a id="idp993688"></a>DbEnv/Db</h4> </div> </div> </div> + <p> + When you open a <code class="classname">DbEnv</code> or + <code class="classname">Db</code> object using + <code class="methodname">dbstl::open_env()</code> or + <code class="methodname">dbstl::open_db()</code>, you do + not need to delete that object. However, if you new'd + that object and then opened it without using the + <code class="methodname">dbstl::open_env()</code> or + <code class="methodname">dbstl::open_db()</code> methods, + you are responsible for deleting the object. + </p> <p> - When you open a <code class="classname">DbEnv</code> or <code class="classname">Db</code> object using - <code class="methodname">dbstl::open_env()</code> or <code class="methodname">dbstl::open_db()</code>, you - do not need to delete that object. However, if you new'd that object and then opened it - without using the <code class="methodname">dbstl::open_env()</code> or - <code class="methodname">dbstl::open_db()</code> methods, you are responsible for deleting the - object. - </p> - <p> - Note that you must <code class="literal">new</code> the <code class="classname">Db</code> or - <code class="classname">DbEnv</code> object, which allocates it on the heap. You can not allocate it - on the stack. If you do, the order of destruction is uncontrollable, which makes dbstl - unable to work properly. - </p> + Note that you must <code class="literal">new</code> the + <code class="classname">Db</code> or + <code class="classname">DbEnv</code> object, which + allocates it on the heap. You can not allocate it on + the stack. If you do, the order of destruction is + uncontrollable, which makes dbstl unable to work + properly. + </p> + <p> + You can call <code class="function">dbstl_exit()</code> + before the process exits, to release any memory + allocated by dbstl that has to live during the entire + process lifetime. Releasing the memory explicitly will + not make much difference, because the process is about + to exit and so all memory allocated on the heap is + going to be returned to the operating system anyway. + The only real difference is that your memory leak + checker will not report false memory leaks. + </p> <p> - You can call <code class="function">dbstl_exit()</code> before the process exits, to release any - memory allocated by dbstl that has to live during the entire process lifetime. Releasing the - memory explicitly will not make much difference, because the process is about to exit and so - all memory allocated on the heap is going to be returned to the operating system anyway. The - only real difference is that your memory leak checker will not report false memory leaks. - </p> + <code class="function">dbstl_exit()</code> releases any memory + allocated by dbstl on the heap. It also performs other + required shutdown operations, such as closing any + databases and environments registered to dbstl and + shared across the process. + </p> <p> - <code class="function">dbstl_exit()</code> releases any memory allocated by dbstl on the heap. It - also performs other required shutdown operations, such as closing any databases and - environments registered to dbstl and shared across the process. - </p> - <p> - If you are calling the <code class="function">dbstl_exit()</code> function, and your - <code class="classname">DbEnv</code> or <code class="classname">Db</code> objects are new'd by your code, - the <code class="function">dbstl_exit()</code> function should be called before deleting the - <code class="classname">DbEnv</code> or <code class="classname">Db</code> objects, because they need to be - closed before being deleted. Alternatively, you can call the - <code class="methodname">dbstl::close_env()</code> or <code class="methodname">dbstl::close_db()</code> - functions before deleting the <code class="classname">DbEnv</code> or <code class="classname">Db</code> - objects in order to explicitly close the databases or environments. If you do this, - can then delete these objects, and then call <code class="function">dbstl_exit()</code>. - </p> - <p> - In addition, before exiting a thread that uses dbstl API, you can call the <code class="function">dbstl_thread_exit() </code>function to release any Berkeley DB handles if they are not used by other threads. - If you do not call the <code class="function">dbstl_thread_exit() </code>function or call this function only in some threads, all open Berkeley DB handles will be closed by the <code class="function">dbstl_exit()</code>function. - You must call the <code class="function">dbstl_exit() </code>function before the process exits, to avoid memory leak and database update loss, if you do not have transactions and persistent log files. - </p> + If you are calling the + <code class="function">dbstl_exit()</code> function, and + your <code class="classname">DbEnv</code> or + <code class="classname">Db</code> objects are new'd by + your code, the <code class="function">dbstl_exit()</code> + function should be called before deleting the + <code class="classname">DbEnv</code> or + <code class="classname">Db</code> objects, because they + need to be closed before being deleted. Alternatively, + you can call the + <code class="methodname">dbstl::close_env()</code> or + <code class="methodname">dbstl::close_db()</code> + functions before deleting the + <code class="classname">DbEnv</code> or + <code class="classname">Db</code> objects in order to + explicitly close the databases or environments. If you + do this, can then delete these objects, and then call + <code class="function">dbstl_exit()</code>. </p> + <p> + In addition, before exiting a thread that uses + dbstl API, you can call the + <code class="function">dbstl_thread_exit() </code>function + to release any Berkeley DB handles if they are not + used by other threads. If you do not call the + <code class="function">dbstl_thread_exit() </code>function + or call this function only in some threads, all open + Berkeley DB handles will be closed by the + <code class="function">dbstl_exit()</code>function. You + must call the <code class="function">dbstl_exit() + </code>function before the process exits, to avoid + memory leak and database update loss, if you do not + have transactions and persistent log files. + </p> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> - <h4 class="title"><a id="idp1410936"></a>DbstlDbt</h4> + <h4 class="title"><a id="idp953376"></a>DbstlDbt</h4> </div> </div> </div> <p> - Only when you are storing raw bytes (such as a bitmap) do you have to - store and retrieve data by using the <code class="classname">DbstlDbt</code> helper class. Although you - also can do so simply by using the Berkeley DB <code class="classname">Dbt</code> class, the - <code class="classname">DbstlDbt</code> class offers more convenient memory management behavior. - </p> - <p> - When you are storing <code class="classname">DbstlDbt</code> objects (such as - <code class="classname">db_vector<DbstlDbt></code>), you <span class="emphasis"><em>must</em></span> allocate - heap memory explicitly using the <code class="function">malloc()</code> function for the - <code class="classname">DbstlDbt</code> object to reference, but you do not need to free the memory - – it is automatically freed by the <code class="classname">DbstlDbt</code> object that owns it - by calling the standard C library <code class="function">free()</code> function. - </p> - <p> - However, because dbstl supports storing any type of object or primitive data, it is rare - that you would have to store data using <code class="classname">DbstlDbt</code> objects while using - dbstl. Examples of storing <code class="classname">DbstlDbt</code> objects can be found in the - <code class="methodname">StlAdvancedFeaturesExample::arbitrary_object_storage()</code> and - <code class="methodname">StlAdvancedFeaturesExample::char_star_string_storage()</code> methods. - </p> + Only when you are storing raw bytes (such as a + bitmap) do you have to store and retrieve data by + using the <code class="classname">DbstlDbt</code> helper + class. Although you also can do so simply by using the + Berkeley DB <code class="classname">Dbt</code> class, the + <code class="classname">DbstlDbt</code> class offers more + convenient memory management behavior. + </p> + <p> + When you are storing + <code class="classname">DbstlDbt</code> objects (such as + <code class="classname">db_vector<DbstlDbt></code>), + you <span class="emphasis"><em>must</em></span> allocate heap memory + explicitly using the <code class="function">malloc()</code> + function for the <code class="classname">DbstlDbt</code> + object to reference, but you do not need to free the + memory – it is automatically freed by the + <code class="classname">DbstlDbt</code> object that owns + it by calling the standard C library + <code class="function">free()</code> function. + </p> + <p> + However, because dbstl supports storing any type of + object or primitive data, it is rare that you would + have to store data using + <code class="classname">DbstlDbt</code> objects while + using dbstl. Examples of storing + <code class="classname">DbstlDbt</code> objects can be + found in the + <code class="methodname">StlAdvancedFeaturesExample::arbitrary_object_storage()</code> + and + <code class="methodname">StlAdvancedFeaturesExample::char_star_string_storage()</code> + methods. + </p> </div> </div> </div> @@ -179,7 +225,8 @@ <td width="40%" align="right"> <a accesskey="n" href="stl_misc.html">Next</a></td> </tr> <tr> - <td width="40%" align="left" valign="top">Using dbstl efficiently </td> + <td width="40%" align="left" valign="top">Using dbstl + efficiently </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> |
