Brute force memory tracking.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4186 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-02-18 21:00:39 +00:00
parent 53cb80ebf7
commit 88c7d91858
8 changed files with 347 additions and 66 deletions

View File

@ -1,9 +1,14 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef struct JSMallocFunctions JSMallocFunctions;
void tf_mem_startup(bool tracking);
void tf_mem_shutdown();
void tf_mem_replace_uv_allocator();
size_t tf_mem_get_uv_malloc_size();
@ -24,3 +29,16 @@ void* tf_resize_vec(void* ptr, size_t size);
void tf_get_js_malloc_functions(JSMallocFunctions* out);
size_t tf_mem_get_js_malloc_size();
void tf_mem_walk_allocations(void (*callback)(void* ptr, size_t size, int frames_count, void* const* frames, void* user_data), void* user_data);
typedef struct _tf_mem_allocation_t
{
uint32_t stack_hash;
int count;
size_t size;
void* frames[32];
int frames_count;
} tf_mem_allocation_t;
tf_mem_allocation_t* tf_mem_summarize_allocations(int* out_count);