From 02607b3103d216dd49ad6fc9ded51773ddb47afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 25 Jul 2017 02:29:46 +0200 Subject: Use atomics for memory use tracking Plus: - An allocation is counted only after checking its success. - Max usage is updated after growing reallocs as well. - Drop unused header. - Changed the 0xFFF.. at get_mem_available() to -1 with a comment telling it's the same, but more universal. --- core/os/memory.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/os/memory.h') diff --git a/core/os/memory.h b/core/os/memory.h index b3eb599955..e1d7138ad5 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -45,20 +45,20 @@ class Memory { Memory(); #ifdef DEBUG_ENABLED - static size_t mem_usage; - static size_t max_usage; + static uint64_t mem_usage; + static uint64_t max_usage; #endif - static size_t alloc_count; + static uint64_t alloc_count; public: static void *alloc_static(size_t p_bytes, bool p_pad_align = false); static void *realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align = false); static void free_static(void *p_ptr, bool p_pad_align = false); - static size_t get_mem_available(); - static size_t get_mem_usage(); - static size_t get_mem_max_usage(); + static uint64_t get_mem_available(); + static uint64_t get_mem_usage(); + static uint64_t get_mem_max_usage(); }; class DefaultAllocator { -- cgit v1.2.3