Skip to content

Commit

Permalink
xrCore/xrMemory.h: allocate additional 16 bytes of memory for RELEASE
Browse files Browse the repository at this point in the history
This will increase memory consumption a bit but I hope this should make
it more stable...

Well, will see if that's true.
  • Loading branch information
Xottab-DUTY committed Jun 9, 2018
1 parent 00b6278 commit f75889c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/xrCore/xrMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

class XRCORE_API xrMemory
{
// Additional 16 bytes of memory almost like in original xr_aligned_offset_malloc
// But for DEBUG we don't need this if we want to find memory problems
#ifdef DEBUG
constexpr size_t reserved = 0;
#else
constexpr size_t reserved = 16;
#endif

public:
xrMemory();
void _initialize();
Expand All @@ -27,9 +35,9 @@ class XRCORE_API xrMemory
public:
size_t mem_usage();
void mem_compact();
inline void* mem_alloc (size_t size) { stat_calls++; return scalable_malloc ( size); };
inline void* mem_realloc(void* ptr, size_t size) { stat_calls++; return scalable_realloc(ptr, size); };
inline void mem_free (void* ptr) { stat_calls++; scalable_free (ptr); };
inline void* mem_alloc (size_t size) { stat_calls++; return scalable_malloc ( size + reserved); };
inline void* mem_realloc(void* ptr, size_t size) { stat_calls++; return scalable_realloc(ptr, size + reserved); };
inline void mem_free (void* ptr) { stat_calls++; scalable_free (ptr); };
};

extern XRCORE_API xrMemory Memory;
Expand Down

0 comments on commit f75889c

Please sign in to comment.