8#include <gtest/gtest.h>
10#include "arccore/common/internal/MemoryPool.h"
11#include "arccore/common/internal/MemoryResourceMng.h"
12#include "arccore/common/internal/MemoryUtilsInternal.h"
14#include "arcane/utils/String.h"
20using namespace Arcane::Impl;
38 MemoryPool memory_pool(&my_allocator,
"MyMemoryPool");
39 size_t max_block_size = 1024 * 8;
40 memory_pool.setMaxCachedBlockSize(1024 * 8);
42 void* a1 = memory_pool.allocateMemory(25);
43 void* a2 = memory_pool.allocateMemory(47);
44 memory_pool.freeMemory(a1, 25);
45 memory_pool.freeMemory(a2, 47);
46 void* a3 = memory_pool.allocateMemory(25);
47 memory_pool.dumpStats(std::cout);
48 memory_pool.dumpFreeMap(std::cout);
49 memory_pool.freeMemory(a3, 25);
51 void* a4 = memory_pool.allocateMemory(max_block_size * 2);
52 memory_pool.freeMemory(a4, max_block_size * 2);
54 std::cout <<
"End Of Test\n";
55 memory_pool.dumpStats(std::cout);
56 memory_pool.dumpFreeMap(std::cout);
57 memory_pool.freeCachedMemory();
64 MemoryPool memory_pool(&my_allocator,
"MyMemoryPool");
69 ASSERT_EQ(p, memory_pool_ptr);
Memory management utility functions.
Interface of a memory pool.
Interface for an allocator for a MemoryPool.
Class to manage a list of allocated zones.
Memory resource management for CPUs and accelerators.
void setMemoryPool(eMemoryResource r, IMemoryPool *pool) override
Sets the memory pool for resource r.
void * allocateMemory(Int64 size) override
Allocates a block for size bytes.
void freeMemory(void *address, Int64) override
Frees the block located at address address containing size bytes.
IMemoryRessourceMng * setDataMemoryResourceMng(IMemoryRessourceMng *mng)
Sets the memory resource manager for data.
IMemoryPool * getMemoryPoolOrNull(eMemoryResource mem_resource)
Memory pool for the resource mem_resource.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
@ Host
Allocates on the host.