Reference documentation for deal.II version 9.2.0
|
#include <deal.II/lac/vector_memory.h>
Classes | |
struct | Pool |
Public Types | |
using | size_type = types::global_dof_index |
Public Member Functions | |
GrowingVectorMemory (const size_type initial_size=0, const bool log_statistics=false) | |
virtual | ~GrowingVectorMemory () override |
virtual VectorType * | alloc () override |
virtual void | free (const VectorType *const) override |
virtual std::size_t | memory_consumption () const |
Public Member Functions inherited from VectorMemory< ::Vector< double > > | |
virtual | ~VectorMemory () override=default |
virtual void | free (const ::Vector< double > *const)=0 |
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 (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
template<typename StreamType > | |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Static Public Member Functions | |
static void | release_unused_memory () |
Static Public Member Functions inherited from VectorMemory< ::Vector< double > > | |
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) |
Private Types | |
using | entry_type = std::pair< bool, std::unique_ptr< VectorType > > |
Static Private Member Functions | |
static Pool & | get_pool () |
Private Attributes | |
size_type | total_alloc |
size_type | current_alloc |
bool | log_statistics |
Static Private Attributes | |
static Threads::Mutex | mutex |
A pool based memory management class. See the documentation of the base class for a description of its purpose.
Each time a vector is requested from this class, it checks if it has one available and returns its address, or allocates a new one on the heap. If a vector is returned from its user, through the GrowingVectorMemory::free() member function, it doesn't return the allocated memory to the operating system memory subsystem, but keeps it around unused for later use if GrowingVectorMemory::alloc() is called again. The class therefore avoid the overhead of repeatedly allocating memory on the heap if temporary vectors are required and released frequently; on the other hand, it doesn't release once-allocated memory at the earliest possible time and may therefore lead to an increased overall memory consumption.
All GrowingVectorMemory objects of the same vector type use the same memory pool. (In other words: The pool of vectors from which this class draws is global, rather than a regular member variable of the current class that is destroyed at the time that the surrounding GrowingVectorMemory object is destroyed.) Therefore, functions can create such a GrowingVectorMemory object whenever needed without the performance penalty of creating a new memory pool every time. A drawback of this policy is that vectors once allocated are only released at the end of the program run.
Definition at line 320 of file vector_memory.h.