Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MemoryPool.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MemoryPool.h (C) 2000-2026 */
9/* */
10/* Classe pour gérer une liste de zone allouées. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_INTERNAL_MEMORYPOOL_H
13#define ARCCORE_COMMON_INTERNAL_MEMORYPOOL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/common/IMemoryPool.h"
18
19#include <memory>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::Impl
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
38class ARCCORE_COMMON_EXPORT IMemoryPoolAllocator
39{
40 public:
41
42 virtual ~IMemoryPoolAllocator() = default;
43
44 public:
45
47 virtual void* allocateMemory(Int64 size) = 0;
49 virtual void freeMemory(void* address, Int64 size) = 0;
50};
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
63class ARCCORE_COMMON_EXPORT MemoryPool
64: public IMemoryPool
66{
67 class Impl;
68
69 public:
70
71 explicit MemoryPool(IMemoryPoolAllocator* allocator, const String& name);
72 ~MemoryPool() override;
73
74 public:
75
76 MemoryPool(const MemoryPool&) = delete;
77 MemoryPool(MemoryPool&&) = delete;
78 MemoryPool& operator=(const MemoryPool&) = delete;
79 MemoryPool& operator=(MemoryPool&&) = delete;
80
81 public:
82
83 void* allocateMemory(Int64 size) override;
84 void freeMemory(void* ptr, Int64 size) override;
85 void dumpStats(std::ostream& ostr);
86 void dumpFreeMap(std::ostream& ostr);
87 String name() const;
88
90
91 void setMaxCachedBlockSize(Int32 v) override;
92 void freeCachedMemory() override;
93 Int64 totalAllocated() const override;
94 Int64 totalCached() const override;
96
97 private:
98
99 std::unique_ptr<Impl> m_p;
100};
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105} // namespace Arcane::Impl
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110#endif
Interface d'un pool mémoire.
Definition IMemoryPool.h:31
Interface d'un allocateur pour un MemoryPool.
Definition MemoryPool.h:39
virtual void freeMemory(void *address, Int64 size)=0
Libère le bloc situé à l'adresse address contenant size octets.
virtual void * allocateMemory(Int64 size)=0
Alloue un bloc pour size octets.
void setMaxCachedBlockSize(Int32 v) override
Implémentation de IMemoryPool.
void freeMemory(void *ptr, Int64 size) override
Libère le bloc situé à l'adresse address contenant size octets.
void * allocateMemory(Int64 size) override
Alloue un bloc pour size octets.
Int64 totalAllocated() const override
Taille totale (en octet) allouée dans le pool mémoire.
void freeCachedMemory() override
Libère la mémoire dans le cache.
Int64 totalCached() const override
Taille totale (en octet) dans le cache.
Chaîne de caractères unicode.
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.