Different output when overriding from `static.c` vs. `mimalloc.o` from cmake
compiling with:
gcc -c -DMI_MALLOC_OVERRIDE -Iinclude -o mimalloc.o src/static.c(is that right? it's not documented well)- vs. the
mimalloc.oproduced from cmake, I get different results fromMIMALLOC_SHOW_STATS=1.
I get different stats results for the same source:
e.g. for the latter I get the line:
touched: 128.5 KiB 192.7 KiB 212.1 MiB -211.9 MiB ok
and for the former:
touched: 192.1 MiB 212.1 MiB 212.1 MiB 69.2 KiB not all freed
for the same mimalloc version the numbers are otherwise consistent across runs and recompilations
My goal is to validate that I'm compiling and overriding malloc correctly
Okay it's also clear I don't know how to build static.c
What I find is that if I link against the mimalloc.o built using the cmake process, things seem to work as expected (I both see mimalloc stats at the end, but also i see a dramatic improvement to memory usage, and obvious effects of the more eager memory decommit behavior).
I've tried compiling static.c in several different ways, and linking it as above, but it hasn't been successful: I do always see output from mimalloc at the end, and it seems to be using the library, But the memory behavior of my program still looks like what I observed with glibc (high memory usage, RSS never shrinks after a pause as it does with mimalloc)
I’ve tried compiling static.c with flags it seems cmake configures for me:
-DMI_MALLOC_OVERRIDE
-DMI_STATIC_LIB
-O3 -DNDEBUG -fPIC -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden -Wstrict-prototypes -ftls-model=initial-exec -fno-builtin-malloc -std=gnu11
…in various combinations, but no luck
I'm hoping to be able to avoid cmake because integration with my project will be much much simpler.