Small memory blocks which are referenced by
struct isc__mem->freelists are never freed (returned to the
operating system).
I’m attaching small demonstration program isc-bugs-35160.c
which does this:
create() empty memory contextget() 1 million of 1 KiB blocksput() all the blocks back to the mctxdestroy() mctxThe program pauses after each step which allows to investigate memory consumption as seen by the operating system.
I compile it with:
$ gcc -std=c99 -ldns -lisc -I/usr/include/bind9 -g -O0 -o isc-bugs-35160 isc-bugs-35160.c
I understand that freelists mechanism saves overhead of the operating system allocator for small blocks, but I’m missing a way how to ‘flush’ freelists.