Skip to content

Commit f75889c

Browse files
committed
xrCore/xrMemory.h: allocate additional 16 bytes of memory for RELEASE
This will increase memory consumption a bit but I hope this should make it more stable... Well, will see if that's true.
1 parent 00b6278 commit f75889c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/xrCore/xrMemory.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
class XRCORE_API xrMemory
1919
{
20+
// Additional 16 bytes of memory almost like in original xr_aligned_offset_malloc
21+
// But for DEBUG we don't need this if we want to find memory problems
22+
#ifdef DEBUG
23+
constexpr size_t reserved = 0;
24+
#else
25+
constexpr size_t reserved = 16;
26+
#endif
27+
2028
public:
2129
xrMemory();
2230
void _initialize();
@@ -27,9 +35,9 @@ class XRCORE_API xrMemory
2735
public:
2836
size_t mem_usage();
2937
void mem_compact();
30-
inline void* mem_alloc (size_t size) { stat_calls++; return scalable_malloc ( size); };
31-
inline void* mem_realloc(void* ptr, size_t size) { stat_calls++; return scalable_realloc(ptr, size); };
32-
inline void mem_free (void* ptr) { stat_calls++; scalable_free (ptr); };
38+
inline void* mem_alloc (size_t size) { stat_calls++; return scalable_malloc ( size + reserved); };
39+
inline void* mem_realloc(void* ptr, size_t size) { stat_calls++; return scalable_realloc(ptr, size + reserved); };
40+
inline void mem_free (void* ptr) { stat_calls++; scalable_free (ptr); };
3341
};
3442

3543
extern XRCORE_API xrMemory Memory;

0 commit comments

Comments
 (0)