Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::PrintableMemoryAllocator Class Reference

Memory allocator via malloc/realloc/free with listing output. More...

#include </__w/arcaneframework.github.io/arcaneframework.github.io/framework/arccore/src/common/arccore/common/DefaultMemoryAllocator.h>

Inheritance diagram for Arcane::PrintableMemoryAllocator:
Collaboration diagram for Arcane::PrintableMemoryAllocator:

Public Member Functions

AllocatedMemoryInfo allocate (MemoryAllocationArgs args, Int64 new_size) override
 Allocates memory for new_size bytes and returns the pointer.
AllocatedMemoryInfo reallocate (MemoryAllocationArgs args, AllocatedMemoryInfo current_ptr, Int64 new_size) override
 Reallocates memory for new_size bytes and returns the pointer.
void deallocate (MemoryAllocationArgs args, AllocatedMemoryInfo ptr) override
 Frees the memory whose base address is ptr.
Public Member Functions inherited from Arcane::DefaultMemoryAllocator
bool hasRealloc (MemoryAllocationArgs) const override
 Indicates whether the allocator supports realloc semantics.
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.

Private Types

using Base = DefaultMemoryAllocator

Detailed Description

Memory allocator via malloc/realloc/free with listing output.

This allocator is primarily used for debugging purposes. Information output is done via std::cout.

Definition at line 62 of file DefaultMemoryAllocator.h.

Member Typedef Documentation

◆ Base

using Arcane::PrintableMemoryAllocator::Base = DefaultMemoryAllocator
private

Definition at line 65 of file DefaultMemoryAllocator.h.

Member Function Documentation

◆ allocate()

AllocatedMemoryInfo Arcane::PrintableMemoryAllocator::allocate ( MemoryAllocationArgs args,
Int64 new_size )
overridevirtual

Allocates memory for new_size bytes and returns the pointer.

The semantics are equivalent to malloc():

  • new_size can be zero, in which case the returned pointer is either null or a specific value
  • the returned pointer may be null if the memory could not be allocated.

Reimplemented from Arcane::DefaultMemoryAllocator.

Definition at line 256 of file MemoryAllocator.cc.

References Arcane::DefaultMemoryAllocator::allocate(), and Arcane::AllocatedMemoryInfo::baseAddress().

Here is the call graph for this function:

◆ deallocate()

void Arcane::PrintableMemoryAllocator::deallocate ( MemoryAllocationArgs args,
AllocatedMemoryInfo ptr )
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.

Reimplemented from Arcane::DefaultMemoryAllocator.

Definition at line 280 of file MemoryAllocator.cc.

References Arcane::AllocatedMemoryInfo::baseAddress(), and Arcane::DefaultMemoryAllocator::deallocate().

Here is the call graph for this function:

◆ reallocate()

AllocatedMemoryInfo Arcane::PrintableMemoryAllocator::reallocate ( MemoryAllocationArgs args,
AllocatedMemoryInfo current_ptr,
Int64 new_size )
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():

  • current_ptr may be null, in which case this call is equivalent to allocate().
  • the returned pointer may be null if the memory could not be allocated.

Reimplemented from Arcane::DefaultMemoryAllocator.

Definition at line 267 of file MemoryAllocator.cc.

References Arcane::AllocatedMemoryInfo::baseAddress(), and Arcane::DefaultMemoryAllocator::reallocate().

Here is the call graph for this function:

The documentation for this class was generated from the following files: