summaryrefslogtreecommitdiff
path: root/core/os/memory.h
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2017-07-25 02:29:46 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2017-08-01 01:50:56 +0200
commit02607b3103d216dd49ad6fc9ded51773ddb47afd (patch)
treec58f84de2505b5942ce65efbaef49f648b85357c /core/os/memory.h
parent3ad68c282ec423080a3e3958b187aaf2e48297c5 (diff)
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.
Diffstat (limited to 'core/os/memory.h')
-rw-r--r--core/os/memory.h12
1 files changed, 6 insertions, 6 deletions
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 {