8#include <gtest/gtest.h>
10#include "arcane/utils/internal/MemoryPool.h"
11#include "arcane/utils/String.h"
17using namespace Arcane::impl;
26 void freeMemory(
void* address,
size_t)
override { std::free(address); }
35 MemoryPool memory_pool(&my_allocator,
"MyMemoryPool");
36 size_t max_block_size = 1024 * 8;
37 memory_pool.setMaxCachedBlockSize(1024 * 8);
39 void* a1 = memory_pool.allocateMemory(25);
40 void* a2 = memory_pool.allocateMemory(47);
41 memory_pool.freeMemory(a1, 25);
42 memory_pool.freeMemory(a2, 47);
43 void* a3 = memory_pool.allocateMemory(25);
44 memory_pool.dumpStats(std::cout);
45 memory_pool.dumpFreeMap(std::cout);
46 memory_pool.freeMemory(a3, 25);
48 void* a4 = memory_pool.allocateMemory(max_block_size * 2);
49 memory_pool.freeMemory(a4, max_block_size * 2);
51 std::cout <<
"End Of Test\n";
52 memory_pool.dumpStats(std::cout);
53 memory_pool.dumpFreeMap(std::cout);
54 memory_pool.freeCachedMemory();
Interface d'un allocateur pour un MemoryPool.
Classe pour gérer une liste de zone allouées.
void freeMemory(void *address, size_t) override
Libère le bloc situé à l'adresse address contenant size octets.
void * allocateMemory(size_t size) override
Alloue un bloc pour size octets.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-