Changeset 539 for library/doc/local
- Timestamp:
- 08/17/09 09:09:10 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/local/memory_management.dox
r533 r539 1 1 /*! 2 \page Memory Management in BDM2 \page memory_management Memory Management in BDM 3 3 4 4 C++ memory management is notoriously flexible, allowing a wide range … … 33 33 library aims to provide the minimal exception safety (that is, 34 34 throwing an exception doesn't crash and doesn't leak any resources) 35 for all thrown exceptions \b except \bmemory errors - when a program35 for all thrown exceptions \b except memory errors - when a program 36 36 using BDM exhausts memory, it should be terminated as soon as possible 37 37 (and in most cases it has probably already terminated by 38 38 itself). Specific exceptions may provide stronger guarantees, as 39 documented for specific cases. All exceptions thrown out sidethe39 documented for specific cases. All exceptions thrown out of the 40 40 library are descendants of std::exception. 41 41 … … 52 52 std::tr1:shared_ptr (which is planned to replace bdm::shared_ptr once 53 53 it becomes widely available). Note that objects allocated on the stack 54 \b must not \bhave their addresses passed to shared_ptr - that is a54 \b must \b not have their addresses passed to shared_ptr - that is a 55 55 bug leading to intermittent runtime errors. 56 56 … … 61 61 62 62 \code 63 // egamma_ptr is typedef for object_ptr<egamma>, whose default 64 // constructor calls new egamma() 63 /* 64 egamma_ptr is typedef for object_ptr<egamma>, whose default 65 constructor calls new egamma() 66 */ 65 67 egamma_ptr eG; 66 68 eG->set_parameters ( a, b ); … … 69 71 Coms ( 0 ) = eG; // object_ptr<T> is derived from shared_ptr<T> 70 72 71 // The egamma instance doesn't leak: if the shared_ptr instance which 72 // wraps it isn't assigned to anything else, the pointer is deleted by 73 // the destructor of either object_ptr, or Array, whichever runs last. 73 /* 74 The egamma instance doesn't leak: if the shared_ptr instance which 75 wraps it isn't assigned to anything else, the pointer is deleted by 76 the destructor of either object_ptr, or Array, whichever runs last. 77 */ 74 78 \endcode 75 79 … … 86 90 87 91 \code 88 / / the pointer must stay valid for the lifetime of the object92 /* the pointer must stay valid for the lifetime of the object */ 89 93 CurrentContext ( const char *name, int idx ); 90 94 \endcode … … 108 112 109 113 \code 110 //! Returns the stored pointer (which remains owned by this 111 //! instance). 114 /* 115 Returns the stored pointer (which remains owned by this 116 instance). 117 */ 112 118 T *get(); 113 119 \endcode