88
99#pragma once
1010
11- #include < spark/buffers/allocators/HugePages.h>
11+ #include < allocators/AllocTrack.h>
12+ #include < allocators/HugePages.h>
1213#include < shared/utility/Utility.h>
1314#include < array>
1415#include < memory>
2930#define EMBER_DEBUG_ALLOCATORS
3031#endif
3132
32- namespace ember ::spark::io {
33+ namespace ember ::allocators {
3334
3435struct NoPageLock {};
3536struct PageLock final : NoPageLock {};
@@ -163,6 +164,7 @@ class BlockAllocator {
163164 }
164165
165166 void initialise (std::size_t elements) {
167+ ALLOC_TRACK (tag_, mem_rep_create);
166168 allocate_storage (elements);
167169 page_lock_conditional ();
168170 initialise_free_list ();
@@ -199,12 +201,14 @@ class BlockAllocator {
199201 ++storage_active_count;
200202#endif
201203 block->meta .using_new = false ;
204+ ALLOC_TRACK (tag_, mem_rep_alloc);
202205 } else {
203206#ifdef EMBER_DEBUG_ALLOCATORS
204207 ++new_active_count;
205208#endif
206209 block = new Block;
207210 block->meta .using_new = true ;
211+ ALLOC_TRACK (tag_, mem_rep_system_alloc);
208212 }
209213
210214 if constexpr (std::is_same_v<ValidatePolicy, ValidateDealloc>) {
@@ -215,6 +219,7 @@ class BlockAllocator {
215219 ++total_allocs;
216220 ++active_count;
217221#endif
222+ ALLOC_TRACK (tag_, mem_rep_bytes_alloc, sizeof (Block));
218223 return new (&block->obj ) _ty (std::forward<Args>(args)...);
219224 }
220225
@@ -233,18 +238,21 @@ class BlockAllocator {
233238#endif
234239 t->~_ty ();
235240 operator delete (block);
241+ ALLOC_TRACK (tag_, mem_rep_system_dealloc);
236242 } else {
237243#ifdef EMBER_DEBUG_ALLOCATORS
238244 --storage_active_count;
239245#endif
240246 t->~_ty ();
241247 push (block);
248+ ALLOC_TRACK (tag_, mem_rep_dealloc);
242249 }
243250
244251#ifdef EMBER_DEBUG_ALLOCATORS
245252 ++total_deallocs;
246253 --active_count;
247254#endif
255+ ALLOC_TRACK (tag_, mem_rep_bytes_dealloc, sizeof (Block));
248256 }
249257
250258 std::string_view tag () const {
@@ -258,7 +266,8 @@ class BlockAllocator {
258266#ifdef EMBER_DEBUG_ALLOCATORS
259267 assert (active_count == 0 );
260268#endif
269+ ALLOC_TRACK (tag_, mem_rep_destroy);
261270 }
262271};
263272
264- } // io, spark , ember
273+ } // allocators , ember
0 commit comments