Reference documentation for deal.II version 9.0.0
|
#include <deal.II/lac/vector_memory.h>
Public Member Functions | |
virtual VectorType * | alloc () |
virtual void | free (const VectorType *const v) |
Public Member Functions inherited from VectorMemory< VectorType > | |
virtual | ~VectorMemory ()=default |
Public Member Functions inherited from Subscriptor | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) noexcept | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (Subscriptor &&) noexcept |
void | subscribe (const char *identifier=nullptr) const |
void | unsubscribe (const char *identifier=nullptr) const |
unsigned int | n_subscriptions () const |
void | list_subscribers () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Additional Inherited Members | |
Static Public Member Functions inherited from VectorMemory< VectorType > | |
static ::ExceptionBase & | ExcNotAllocatedHere () |
Static Public Member Functions inherited from Subscriptor | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Simple memory management. See the documentation of the base class for a description of its purpose.
This class allocates and deletes vectors as needed from the global heap, i.e. performs no specially adapted actions for memory management.
Definition at line 234 of file vector_memory.h.
|
virtual |
Return a pointer to a new vector. The number of elements or their subdivision into blocks (if applicable) is unspecified and users of this function should reset vectors to their proper size. The same holds for the contents of vectors: they are unspecified. In other words, the place that calls this function will need to resize or reinitialize it appropriately.
For the present class, calling this function will allocate a new vector on the heap and returning a pointer to it. Later calling free() then returns the memory to the global heap managed by the operating system.
new
and delete
explicitly in code invites bugs where memory is leaked (either because the corresponding delete
is forgotten altogether, or because of exception safety issues), using the alloc() and free() functions explicitly invites writing code that accidentally leaks memory. You should consider using the VectorMemory::Pointer class instead, which provides the same kind of service that std::unique
provides for arbitrary memory allocated on the heap. Implements VectorMemory< VectorType >.
|
virtual |
Return a vector and indicate that it is not going to be used any further by the instance that called alloc() to get a pointer to it.
For the present class, this means that the vector is returned to the global heap.
new
and delete
explicitly in code invites bugs where memory is leaked (either because the corresponding delete
is forgotten altogether, or because of exception safety issues), using the alloc() and free() functions explicitly invites writing code that accidentally leaks memory. You should consider using the VectorMemory::Pointer class instead, which provides the same kind of service that std::unique
provides for arbitrary memory allocated on the heap. Implements VectorMemory< VectorType >.