MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / main

Function main

test/test_emmalloc_memory_statistics.c:9–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7}
8
9int main() {
10 void *ptr = malloc(32*1024*1024);
11 void *ptr2 = malloc(4*1024*1024);
12 void *ptr3 = malloc(64*1024*1024);
13 void *ptr4 = malloc(16*1024);
14 void *ptr5 = malloc(2*1024*1024);
15 EM_ASM({}, ptr, ptr2, ptr3, ptr4, ptr5); // Use allocation pointers in an extern call site to avoid them being optimized away
16 printf("valid allocs: %d\n", (int)(ptr && ptr2 && ptr3 && ptr4 && ptr5));
17 free(ptr2);
18 free(ptr4);
19 printf("emmalloc_validate_memory_regions: %d\n", emmalloc_validate_memory_regions());
20 printf("emmalloc_dynamic_heap_size : %zu\n", emmalloc_dynamic_heap_size());
21 printf("emmalloc_free_dynamic_memory : %zu\n", emmalloc_free_dynamic_memory());
22 emmalloc_dump_free_dynamic_memory_fragmentation_map();
23 printf("emmalloc_unclaimed_heap_memory : %zu\n", round_to_4k(emmalloc_unclaimed_heap_memory()));
24}

Callers

nothing calls this directly

Calls 10

printfFunction · 0.85
round_to_4kFunction · 0.70
mallocFunction · 0.50
EM_ASMFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected