mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add Tracy memory instrumentation
Does not capture C++17 aligned new/delete.
This commit is contained in:
parent
42e5646c15
commit
17f6f9297a
2 changed files with 17 additions and 0 deletions
|
|
@ -355,3 +355,16 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void* operator new(size_t count)
|
||||||
|
{
|
||||||
|
auto p = malloc(count);
|
||||||
|
TracyAlloc(p, count);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void* ptr)
|
||||||
|
{
|
||||||
|
TracyFree(ptr);
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
/// allocator was fragmenting badly. Finally, this version is a bit
|
/// allocator was fragmenting badly. Finally, this version is a bit
|
||||||
/// simpler (about half the lines of code).
|
/// simpler (about half the lines of code).
|
||||||
|
|
||||||
|
#include <tracy/tracy/TracyC.h>
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "r_patch.h"
|
#include "r_patch.h"
|
||||||
|
|
@ -200,6 +202,7 @@ void Z_Free2(void *ptr, const char *file, INT32 line)
|
||||||
*block->user = NULL;
|
*block->user = NULL;
|
||||||
|
|
||||||
// Free the memory and get rid of the block.
|
// Free the memory and get rid of the block.
|
||||||
|
TracyCFree(block->real);
|
||||||
free(block->real);
|
free(block->real);
|
||||||
#ifdef VALGRIND_DESTROY_MEMPOOL
|
#ifdef VALGRIND_DESTROY_MEMPOOL
|
||||||
VALGRIND_DESTROY_MEMPOOL(block);
|
VALGRIND_DESTROY_MEMPOOL(block);
|
||||||
|
|
@ -273,6 +276,7 @@ void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
|
||||||
padsize += (1<<sizeof(size_t))*2;
|
padsize += (1<<sizeof(size_t))*2;
|
||||||
#endif
|
#endif
|
||||||
ptr = xm(blocksize + padsize*2);
|
ptr = xm(blocksize + padsize*2);
|
||||||
|
TracyCAlloc(ptr, blocksize);
|
||||||
|
|
||||||
// This horrible calculation makes sure that "given" is aligned
|
// This horrible calculation makes sure that "given" is aligned
|
||||||
// properly.
|
// properly.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue