Memory allocator via malloc/realloc/free. More...
Public Member Functions | |
| bool | hasRealloc (MemoryAllocationArgs) const override |
| Indicates whether the allocator supports realloc semantics. | |
| AllocatedMemoryInfo | allocate (MemoryAllocationArgs, Int64 new_size) override |
| Allocates memory for new_size bytes and returns the pointer. | |
| AllocatedMemoryInfo | reallocate (MemoryAllocationArgs, AllocatedMemoryInfo current_ptr, Int64 new_size) override |
| Reallocates memory for new_size bytes and returns the pointer. | |
| void | deallocate (MemoryAllocationArgs, AllocatedMemoryInfo ptr) override |
| Frees the memory whose base address is ptr. | |
| Int64 | adjustedCapacity (MemoryAllocationArgs, Int64 wanted_capacity, Int64 element_size) const override |
| Adjusts the capacity based on the element size. | |
| size_t | guaranteedAlignment (MemoryAllocationArgs) const override |
| Value of the alignment guaranteed by the allocator. | |
| eMemoryResource | memoryResource () const override |
| Memory resource provided by the allocator. | |
| Public Member Functions inherited from Arcane::IMemoryAllocator | |
| virtual | ~IMemoryAllocator ()=default |
| Destroys the allocator. | |
| virtual size_t | guarantedAlignment (MemoryAllocationArgs args) const |
| Value of the alignment guaranteed by the allocator. | |
| virtual void | notifyMemoryArgsChanged (MemoryAllocationArgs old_args, MemoryAllocationArgs new_args, AllocatedMemoryInfo ptr) |
| Notifies of a change in instance-specific arguments. | |
| virtual void | copyMemory (MemoryAllocationArgs args, AllocatedMemoryInfo destination, AllocatedMemoryInfo source) |
| Copies memory between two regions. | |
| virtual bool | isCollective () const |
| Indicates whether calls to the allocator must be performed collectively. | |
Static Private Attributes | |
| static DefaultMemoryAllocator | shared_null_instance |
Friends | |
| class | ArrayMetaData |
Memory allocator via malloc/realloc/free.
TODO: mark methods as 'final'.
Definition at line 33 of file DefaultMemoryAllocator.h.
|
overridevirtual |
Adjusts the capacity based on the element size.
This method is used to optionally modify the number of allocated elements based on their size. This allows, for example, aligned allocators to ensure that the number of elements allocated is a multiple of this alignment.
Implements Arcane::IMemoryAllocator.
Definition at line 117 of file MemoryAllocator.cc.
|
overridevirtual |
Allocates memory for new_size bytes and returns the pointer.
The semantics are equivalent to malloc():
Implements Arcane::IMemoryAllocator.
Reimplemented in Arcane::PrintableMemoryAllocator, and Arccore::PrintableMemoryAllocator.
Definition at line 90 of file MemoryAllocator.cc.
Referenced by Arcane::PrintableMemoryAllocator::allocate().
|
overridevirtual |
Frees the memory whose base address is ptr.
The pointer ptr must have been allocated via a call to allocate() or reallocate() on this instance.
The semantics of this method are equivalent to free(), and thus ptr may be null, in which case no operation is performed.
Implements Arcane::IMemoryAllocator.
Reimplemented in Arcane::PrintableMemoryAllocator, and Arccore::PrintableMemoryAllocator.
Definition at line 108 of file MemoryAllocator.cc.
References Arcane::AllocatedMemoryInfo::baseAddress().
Referenced by Arcane::PrintableMemoryAllocator::deallocate().
|
inlineoverridevirtual |
Value of the alignment guaranteed by the allocator.
This method ensures that an allocator has sufficient alignment for certain operations such as vectorization, for example.
If there is no guarantee, it returns 0.
Implements Arcane::IMemoryAllocator.
Definition at line 49 of file DefaultMemoryAllocator.h.
|
overridevirtual |
Indicates whether the allocator supports realloc semantics.
Default C allocators (malloc/realloc/free) obviously support realloc, but this is not necessarily the case for specific allocators with memory alignment (such as posix_memalign).
Reimplemented from Arcane::IMemoryAllocator.
Definition at line 81 of file MemoryAllocator.cc.
|
inlineoverridevirtual |
Memory resource provided by the allocator.
Reimplemented from Arcane::IMemoryAllocator.
Definition at line 50 of file DefaultMemoryAllocator.h.
References Arcane::Host.
|
overridevirtual |
Reallocates memory for new_size bytes and returns the pointer.
The pointer current_ptr must have been allocated via a call to allocate() or reallocate() on this instance.
The semantics of this method are equivalent to realloc():
Implements Arcane::IMemoryAllocator.
Reimplemented in Arcane::PrintableMemoryAllocator, and Arccore::PrintableMemoryAllocator.
Definition at line 99 of file MemoryAllocator.cc.
References Arcane::AllocatedMemoryInfo::baseAddress().
Referenced by Arcane::PrintableMemoryAllocator::reallocate().
|
friend |
Definition at line 36 of file DefaultMemoryAllocator.h.
|
staticprivate |
Definition at line 40 of file DefaultMemoryAllocator.h.