malloc.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/Debug.h>
  7. #include <AK/ScopedValueRollback.h>
  8. #include <AK/Vector.h>
  9. #include <LibELF/AuxiliaryVector.h>
  10. #include <assert.h>
  11. #include <errno.h>
  12. #include <mallocdefs.h>
  13. #include <pthread.h>
  14. #include <serenity.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <sys/internals.h>
  19. #include <sys/mman.h>
  20. #include <syscall.h>
  21. class PthreadMutexLocker {
  22. public:
  23. ALWAYS_INLINE explicit PthreadMutexLocker(pthread_mutex_t& mutex)
  24. : m_mutex(mutex)
  25. {
  26. lock();
  27. __heap_is_stable = false;
  28. }
  29. ALWAYS_INLINE ~PthreadMutexLocker()
  30. {
  31. __heap_is_stable = true;
  32. unlock();
  33. }
  34. ALWAYS_INLINE void lock() { pthread_mutex_lock(&m_mutex); }
  35. ALWAYS_INLINE void unlock() { pthread_mutex_unlock(&m_mutex); }
  36. private:
  37. pthread_mutex_t& m_mutex;
  38. };
  39. #define RECYCLE_BIG_ALLOCATIONS
  40. static pthread_mutex_t s_malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
  41. bool __heap_is_stable = true;
  42. constexpr size_t number_of_hot_chunked_blocks_to_keep_around = 16;
  43. constexpr size_t number_of_cold_chunked_blocks_to_keep_around = 16;
  44. constexpr size_t number_of_big_blocks_to_keep_around_per_size_class = 8;
  45. static bool s_log_malloc = false;
  46. static bool s_scrub_malloc = true;
  47. static bool s_scrub_free = true;
  48. static bool s_profiling = false;
  49. static bool s_in_userspace_emulator = false;
  50. ALWAYS_INLINE static void ue_notify_malloc(const void* ptr, size_t size)
  51. {
  52. if (s_in_userspace_emulator)
  53. syscall(SC_emuctl, 1, size, (FlatPtr)ptr);
  54. }
  55. ALWAYS_INLINE static void ue_notify_free(const void* ptr)
  56. {
  57. if (s_in_userspace_emulator)
  58. syscall(SC_emuctl, 2, (FlatPtr)ptr, 0);
  59. }
  60. ALWAYS_INLINE static void ue_notify_realloc(const void* ptr, size_t size)
  61. {
  62. if (s_in_userspace_emulator)
  63. syscall(SC_emuctl, 3, size, (FlatPtr)ptr);
  64. }
  65. ALWAYS_INLINE static void ue_notify_chunk_size_changed(const void* block, size_t chunk_size)
  66. {
  67. if (s_in_userspace_emulator)
  68. syscall(SC_emuctl, 4, chunk_size, (FlatPtr)block);
  69. }
  70. struct MemoryAuditingSuppressor {
  71. ALWAYS_INLINE MemoryAuditingSuppressor()
  72. {
  73. if (s_in_userspace_emulator)
  74. syscall(SC_emuctl, 7);
  75. }
  76. ALWAYS_INLINE ~MemoryAuditingSuppressor()
  77. {
  78. if (s_in_userspace_emulator)
  79. syscall(SC_emuctl, 8);
  80. }
  81. };
  82. struct MallocStats {
  83. size_t number_of_malloc_calls;
  84. size_t number_of_big_allocator_hits;
  85. size_t number_of_big_allocator_purge_hits;
  86. size_t number_of_big_allocs;
  87. size_t number_of_hot_empty_block_hits;
  88. size_t number_of_cold_empty_block_hits;
  89. size_t number_of_cold_empty_block_purge_hits;
  90. size_t number_of_block_allocs;
  91. size_t number_of_blocks_full;
  92. size_t number_of_free_calls;
  93. size_t number_of_big_allocator_keeps;
  94. size_t number_of_big_allocator_frees;
  95. size_t number_of_freed_full_blocks;
  96. size_t number_of_hot_keeps;
  97. size_t number_of_cold_keeps;
  98. size_t number_of_frees;
  99. };
  100. static MallocStats g_malloc_stats = {};
  101. static size_t s_hot_empty_block_count { 0 };
  102. static ChunkedBlock* s_hot_empty_blocks[number_of_hot_chunked_blocks_to_keep_around] { nullptr };
  103. static size_t s_cold_empty_block_count { 0 };
  104. static ChunkedBlock* s_cold_empty_blocks[number_of_cold_chunked_blocks_to_keep_around] { nullptr };
  105. struct Allocator {
  106. size_t size { 0 };
  107. size_t block_count { 0 };
  108. ChunkedBlock::List usable_blocks;
  109. ChunkedBlock::List full_blocks;
  110. };
  111. struct BigAllocator {
  112. Vector<BigAllocationBlock*, number_of_big_blocks_to_keep_around_per_size_class> blocks;
  113. };
  114. // Allocators will be initialized in __malloc_init.
  115. // We can not rely on global constructors to initialize them,
  116. // because they must be initialized before other global constructors
  117. // are run. Similarly, we can not allow global destructors to destruct
  118. // them. We could have used AK::NeverDestoyed to prevent the latter,
  119. // but it would have not helped with the former.
  120. alignas(Allocator) static u8 g_allocators_storage[sizeof(Allocator) * num_size_classes];
  121. alignas(BigAllocator) static u8 g_big_allocators_storage[sizeof(BigAllocator)];
  122. static inline Allocator (&allocators())[num_size_classes]
  123. {
  124. return reinterpret_cast<Allocator(&)[num_size_classes]>(g_allocators_storage);
  125. }
  126. static inline BigAllocator (&big_allocators())[1]
  127. {
  128. return reinterpret_cast<BigAllocator(&)[1]>(g_big_allocators_storage);
  129. }
  130. static Allocator* allocator_for_size(size_t size, size_t& good_size)
  131. {
  132. for (size_t i = 0; size_classes[i]; ++i) {
  133. if (size <= size_classes[i]) {
  134. good_size = size_classes[i];
  135. return &allocators()[i];
  136. }
  137. }
  138. good_size = PAGE_ROUND_UP(size);
  139. return nullptr;
  140. }
  141. #ifdef RECYCLE_BIG_ALLOCATIONS
  142. static BigAllocator* big_allocator_for_size(size_t size)
  143. {
  144. if (size == 65536)
  145. return &big_allocators()[0];
  146. return nullptr;
  147. }
  148. #endif
  149. extern "C" {
  150. static void* os_alloc(size_t size, const char* name)
  151. {
  152. int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_PURGEABLE;
  153. #if ARCH(X86_64)
  154. flags |= MAP_RANDOMIZED;
  155. #endif
  156. auto* ptr = serenity_mmap(nullptr, size, PROT_READ | PROT_WRITE, flags, 0, 0, ChunkedBlock::block_size, name);
  157. VERIFY(ptr != MAP_FAILED);
  158. return ptr;
  159. }
  160. static void os_free(void* ptr, size_t size)
  161. {
  162. int rc = munmap(ptr, size);
  163. assert(rc == 0);
  164. }
  165. enum class CallerWillInitializeMemory {
  166. No,
  167. Yes,
  168. };
  169. static void* malloc_impl(size_t size, CallerWillInitializeMemory caller_will_initialize_memory)
  170. {
  171. if (s_log_malloc)
  172. dbgln("LibC: malloc({})", size);
  173. if (!size) {
  174. // Legally we could just return a null pointer here, but this is more
  175. // compatible with existing software.
  176. size = 1;
  177. }
  178. g_malloc_stats.number_of_malloc_calls++;
  179. size_t good_size;
  180. auto* allocator = allocator_for_size(size, good_size);
  181. PthreadMutexLocker locker(s_malloc_mutex);
  182. if (!allocator) {
  183. size_t real_size = round_up_to_power_of_two(sizeof(BigAllocationBlock) + size, ChunkedBlock::block_size);
  184. #ifdef RECYCLE_BIG_ALLOCATIONS
  185. if (auto* allocator = big_allocator_for_size(real_size)) {
  186. if (!allocator->blocks.is_empty()) {
  187. g_malloc_stats.number_of_big_allocator_hits++;
  188. auto* block = allocator->blocks.take_last();
  189. int rc = madvise(block, real_size, MADV_SET_NONVOLATILE);
  190. bool this_block_was_purged = rc == 1;
  191. if (rc < 0) {
  192. perror("madvise");
  193. VERIFY_NOT_REACHED();
  194. }
  195. if (mprotect(block, real_size, PROT_READ | PROT_WRITE) < 0) {
  196. perror("mprotect");
  197. VERIFY_NOT_REACHED();
  198. }
  199. if (this_block_was_purged) {
  200. g_malloc_stats.number_of_big_allocator_purge_hits++;
  201. new (block) BigAllocationBlock(real_size);
  202. }
  203. ue_notify_malloc(&block->m_slot[0], size);
  204. return &block->m_slot[0];
  205. }
  206. }
  207. #endif
  208. g_malloc_stats.number_of_big_allocs++;
  209. auto* block = (BigAllocationBlock*)os_alloc(real_size, "malloc: BigAllocationBlock");
  210. new (block) BigAllocationBlock(real_size);
  211. ue_notify_malloc(&block->m_slot[0], size);
  212. return &block->m_slot[0];
  213. }
  214. ChunkedBlock* block = nullptr;
  215. for (auto& current : allocator->usable_blocks) {
  216. if (current.free_chunks()) {
  217. block = &current;
  218. break;
  219. }
  220. }
  221. if (!block && s_hot_empty_block_count) {
  222. g_malloc_stats.number_of_hot_empty_block_hits++;
  223. block = s_hot_empty_blocks[--s_hot_empty_block_count];
  224. if (block->m_size != good_size) {
  225. new (block) ChunkedBlock(good_size);
  226. ue_notify_chunk_size_changed(block, good_size);
  227. char buffer[64];
  228. snprintf(buffer, sizeof(buffer), "malloc: ChunkedBlock(%zu)", good_size);
  229. set_mmap_name(block, ChunkedBlock::block_size, buffer);
  230. }
  231. allocator->usable_blocks.append(*block);
  232. }
  233. if (!block && s_cold_empty_block_count) {
  234. g_malloc_stats.number_of_cold_empty_block_hits++;
  235. block = s_cold_empty_blocks[--s_cold_empty_block_count];
  236. int rc = madvise(block, ChunkedBlock::block_size, MADV_SET_NONVOLATILE);
  237. bool this_block_was_purged = rc == 1;
  238. if (rc < 0) {
  239. perror("madvise");
  240. VERIFY_NOT_REACHED();
  241. }
  242. rc = mprotect(block, ChunkedBlock::block_size, PROT_READ | PROT_WRITE);
  243. if (rc < 0) {
  244. perror("mprotect");
  245. VERIFY_NOT_REACHED();
  246. }
  247. if (this_block_was_purged || block->m_size != good_size) {
  248. if (this_block_was_purged)
  249. g_malloc_stats.number_of_cold_empty_block_purge_hits++;
  250. new (block) ChunkedBlock(good_size);
  251. ue_notify_chunk_size_changed(block, good_size);
  252. }
  253. allocator->usable_blocks.append(*block);
  254. }
  255. if (!block) {
  256. g_malloc_stats.number_of_block_allocs++;
  257. char buffer[64];
  258. snprintf(buffer, sizeof(buffer), "malloc: ChunkedBlock(%zu)", good_size);
  259. block = (ChunkedBlock*)os_alloc(ChunkedBlock::block_size, buffer);
  260. new (block) ChunkedBlock(good_size);
  261. allocator->usable_blocks.append(*block);
  262. ++allocator->block_count;
  263. }
  264. --block->m_free_chunks;
  265. void* ptr = block->m_freelist;
  266. if (ptr) {
  267. block->m_freelist = block->m_freelist->next;
  268. } else {
  269. ptr = block->m_slot + block->m_next_lazy_freelist_index * block->m_size;
  270. block->m_next_lazy_freelist_index++;
  271. }
  272. VERIFY(ptr);
  273. if (block->is_full()) {
  274. g_malloc_stats.number_of_blocks_full++;
  275. dbgln_if(MALLOC_DEBUG, "Block {:p} is now full in size class {}", block, good_size);
  276. allocator->usable_blocks.remove(*block);
  277. allocator->full_blocks.append(*block);
  278. }
  279. dbgln_if(MALLOC_DEBUG, "LibC: allocated {:p} (chunk in block {:p}, size {})", ptr, block, block->bytes_per_chunk());
  280. if (s_scrub_malloc && caller_will_initialize_memory == CallerWillInitializeMemory::No)
  281. memset(ptr, MALLOC_SCRUB_BYTE, block->m_size);
  282. ue_notify_malloc(ptr, size);
  283. return ptr;
  284. }
  285. static void free_impl(void* ptr)
  286. {
  287. ScopedValueRollback rollback(errno);
  288. if (!ptr)
  289. return;
  290. g_malloc_stats.number_of_free_calls++;
  291. void* block_base = (void*)((FlatPtr)ptr & ChunkedBlock::ChunkedBlock::block_mask);
  292. size_t magic = *(size_t*)block_base;
  293. PthreadMutexLocker locker(s_malloc_mutex);
  294. if (magic == MAGIC_BIGALLOC_HEADER) {
  295. auto* block = (BigAllocationBlock*)block_base;
  296. #ifdef RECYCLE_BIG_ALLOCATIONS
  297. if (auto* allocator = big_allocator_for_size(block->m_size)) {
  298. if (allocator->blocks.size() < number_of_big_blocks_to_keep_around_per_size_class) {
  299. g_malloc_stats.number_of_big_allocator_keeps++;
  300. allocator->blocks.append(block);
  301. size_t this_block_size = block->m_size;
  302. if (mprotect(block, this_block_size, PROT_NONE) < 0) {
  303. perror("mprotect");
  304. VERIFY_NOT_REACHED();
  305. }
  306. if (madvise(block, this_block_size, MADV_SET_VOLATILE) != 0) {
  307. perror("madvise");
  308. VERIFY_NOT_REACHED();
  309. }
  310. return;
  311. }
  312. }
  313. #endif
  314. g_malloc_stats.number_of_big_allocator_frees++;
  315. os_free(block, block->m_size);
  316. return;
  317. }
  318. assert(magic == MAGIC_PAGE_HEADER);
  319. auto* block = (ChunkedBlock*)block_base;
  320. dbgln_if(MALLOC_DEBUG, "LibC: freeing {:p} in allocator {:p} (size={}, used={})", ptr, block, block->bytes_per_chunk(), block->used_chunks());
  321. if (s_scrub_free)
  322. memset(ptr, FREE_SCRUB_BYTE, block->bytes_per_chunk());
  323. auto* entry = (FreelistEntry*)ptr;
  324. entry->next = block->m_freelist;
  325. block->m_freelist = entry;
  326. if (block->is_full()) {
  327. size_t good_size;
  328. auto* allocator = allocator_for_size(block->m_size, good_size);
  329. dbgln_if(MALLOC_DEBUG, "Block {:p} no longer full in size class {}", block, good_size);
  330. g_malloc_stats.number_of_freed_full_blocks++;
  331. allocator->full_blocks.remove(*block);
  332. allocator->usable_blocks.prepend(*block);
  333. }
  334. ++block->m_free_chunks;
  335. if (!block->used_chunks()) {
  336. size_t good_size;
  337. auto* allocator = allocator_for_size(block->m_size, good_size);
  338. if (s_hot_empty_block_count < number_of_hot_chunked_blocks_to_keep_around) {
  339. dbgln_if(MALLOC_DEBUG, "Keeping hot block {:p} around", block);
  340. g_malloc_stats.number_of_hot_keeps++;
  341. allocator->usable_blocks.remove(*block);
  342. s_hot_empty_blocks[s_hot_empty_block_count++] = block;
  343. return;
  344. }
  345. if (s_cold_empty_block_count < number_of_cold_chunked_blocks_to_keep_around) {
  346. dbgln_if(MALLOC_DEBUG, "Keeping cold block {:p} around", block);
  347. g_malloc_stats.number_of_cold_keeps++;
  348. allocator->usable_blocks.remove(*block);
  349. s_cold_empty_blocks[s_cold_empty_block_count++] = block;
  350. mprotect(block, ChunkedBlock::block_size, PROT_NONE);
  351. madvise(block, ChunkedBlock::block_size, MADV_SET_VOLATILE);
  352. return;
  353. }
  354. dbgln_if(MALLOC_DEBUG, "Releasing block {:p} for size class {}", block, good_size);
  355. g_malloc_stats.number_of_frees++;
  356. allocator->usable_blocks.remove(*block);
  357. --allocator->block_count;
  358. os_free(block, ChunkedBlock::block_size);
  359. }
  360. }
  361. void* malloc(size_t size)
  362. {
  363. MemoryAuditingSuppressor suppressor;
  364. void* ptr = malloc_impl(size, CallerWillInitializeMemory::No);
  365. if (s_profiling)
  366. perf_event(PERF_EVENT_MALLOC, size, reinterpret_cast<FlatPtr>(ptr));
  367. return ptr;
  368. }
  369. // This is a Microsoft extension, and is not found on other Unix-like systems.
  370. // FIXME: Implement aligned_alloc() instead
  371. //
  372. // This is used in libc++ to implement C++17 aligned new/delete.
  373. //
  374. // Both Unix-y alternatives to _aligned_malloc(), the C11 aligned_alloc() and
  375. // posix_memalign() say that the resulting pointer can be deallocated with
  376. // regular free(), which means that the allocator has to keep track of the
  377. // requested alignments. By contrast, _aligned_malloc() is paired with
  378. // _aligned_free(), so it can be easily implemented on top of malloc().
  379. void* _aligned_malloc(size_t size, size_t alignment)
  380. {
  381. if (__builtin_popcount(alignment) != 1) {
  382. errno = EINVAL;
  383. return nullptr;
  384. }
  385. alignment = max(alignment, sizeof(void*));
  386. if (Checked<size_t>::addition_would_overflow(size, alignment)) {
  387. errno = ENOMEM;
  388. return nullptr;
  389. }
  390. void* ptr = malloc(size + alignment);
  391. if (!ptr) {
  392. errno = ENOMEM;
  393. return nullptr;
  394. }
  395. auto aligned_ptr = (void*)(((FlatPtr)ptr + alignment) & ~(alignment - 1));
  396. ((void**)aligned_ptr)[-1] = ptr;
  397. return aligned_ptr;
  398. }
  399. void free(void* ptr)
  400. {
  401. MemoryAuditingSuppressor suppressor;
  402. if (s_profiling)
  403. perf_event(PERF_EVENT_FREE, reinterpret_cast<FlatPtr>(ptr), 0);
  404. ue_notify_free(ptr);
  405. free_impl(ptr);
  406. }
  407. void _aligned_free(void* ptr)
  408. {
  409. if (ptr)
  410. free(((void**)ptr)[-1]);
  411. }
  412. void* calloc(size_t count, size_t size)
  413. {
  414. MemoryAuditingSuppressor suppressor;
  415. if (Checked<size_t>::multiplication_would_overflow(count, size)) {
  416. errno = ENOMEM;
  417. return nullptr;
  418. }
  419. size_t new_size = count * size;
  420. auto* ptr = malloc_impl(new_size, CallerWillInitializeMemory::Yes);
  421. if (ptr)
  422. memset(ptr, 0, new_size);
  423. return ptr;
  424. }
  425. size_t malloc_size(void* ptr)
  426. {
  427. MemoryAuditingSuppressor suppressor;
  428. if (!ptr)
  429. return 0;
  430. void* page_base = (void*)((FlatPtr)ptr & ChunkedBlock::block_mask);
  431. auto* header = (const CommonHeader*)page_base;
  432. auto size = header->m_size;
  433. if (header->m_magic == MAGIC_BIGALLOC_HEADER)
  434. size -= sizeof(CommonHeader);
  435. else
  436. VERIFY(header->m_magic == MAGIC_PAGE_HEADER);
  437. return size;
  438. }
  439. size_t malloc_good_size(size_t size)
  440. {
  441. size_t good_size;
  442. allocator_for_size(size, good_size);
  443. return good_size;
  444. }
  445. void* realloc(void* ptr, size_t size)
  446. {
  447. MemoryAuditingSuppressor suppressor;
  448. if (!ptr)
  449. return malloc(size);
  450. if (!size) {
  451. free(ptr);
  452. return nullptr;
  453. }
  454. auto existing_allocation_size = malloc_size(ptr);
  455. if (size <= existing_allocation_size) {
  456. ue_notify_realloc(ptr, size);
  457. return ptr;
  458. }
  459. auto* new_ptr = malloc(size);
  460. if (new_ptr) {
  461. memcpy(new_ptr, ptr, min(existing_allocation_size, size));
  462. free(ptr);
  463. }
  464. return new_ptr;
  465. }
  466. void __malloc_init()
  467. {
  468. s_in_userspace_emulator = (int)syscall(SC_emuctl, 0) != -ENOSYS;
  469. if (s_in_userspace_emulator) {
  470. // Don't bother scrubbing memory if we're running in UE since it
  471. // keeps track of heap memory anyway.
  472. s_scrub_malloc = false;
  473. s_scrub_free = false;
  474. }
  475. if (secure_getenv("LIBC_NOSCRUB_MALLOC"))
  476. s_scrub_malloc = false;
  477. if (secure_getenv("LIBC_NOSCRUB_FREE"))
  478. s_scrub_free = false;
  479. if (secure_getenv("LIBC_LOG_MALLOC"))
  480. s_log_malloc = true;
  481. if (secure_getenv("LIBC_PROFILE_MALLOC"))
  482. s_profiling = true;
  483. for (size_t i = 0; i < num_size_classes; ++i) {
  484. new (&allocators()[i]) Allocator();
  485. allocators()[i].size = size_classes[i];
  486. }
  487. new (&big_allocators()[0])(BigAllocator);
  488. }
  489. void serenity_dump_malloc_stats()
  490. {
  491. dbgln("# malloc() calls: {}", g_malloc_stats.number_of_malloc_calls);
  492. dbgln();
  493. dbgln("big alloc hits: {}", g_malloc_stats.number_of_big_allocator_hits);
  494. dbgln("big alloc hits that were purged: {}", g_malloc_stats.number_of_big_allocator_purge_hits);
  495. dbgln("big allocs: {}", g_malloc_stats.number_of_big_allocs);
  496. dbgln();
  497. dbgln("empty hot block hits: {}", g_malloc_stats.number_of_hot_empty_block_hits);
  498. dbgln("empty cold block hits: {}", g_malloc_stats.number_of_cold_empty_block_hits);
  499. dbgln("empty cold block hits that were purged: {}", g_malloc_stats.number_of_cold_empty_block_purge_hits);
  500. dbgln("block allocs: {}", g_malloc_stats.number_of_block_allocs);
  501. dbgln("filled blocks: {}", g_malloc_stats.number_of_blocks_full);
  502. dbgln();
  503. dbgln("# free() calls: {}", g_malloc_stats.number_of_free_calls);
  504. dbgln();
  505. dbgln("big alloc keeps: {}", g_malloc_stats.number_of_big_allocator_keeps);
  506. dbgln("big alloc frees: {}", g_malloc_stats.number_of_big_allocator_frees);
  507. dbgln();
  508. dbgln("full block frees: {}", g_malloc_stats.number_of_freed_full_blocks);
  509. dbgln("number of hot keeps: {}", g_malloc_stats.number_of_hot_keeps);
  510. dbgln("number of cold keeps: {}", g_malloc_stats.number_of_cold_keeps);
  511. dbgln("number of frees: {}", g_malloc_stats.number_of_frees);
  512. }
  513. }