I did some more digging and than made a bug report with Curl upstream here: <https://github.com/curl/curl/issues/6990>. This produced a commit there that makes my test work much better.
The glibc function mallinfo still says that a couple of bytes go missing now and than, but valgrind says it can't find anything. I also repeated the test 20000 times and watched the memory in htop and it didn't grow, so I will assume this is an error with mallinfo. Thank you for your attention and your patience. Regards, benny