The fontconfig library has a function FcFini
.
The docs just say
FcFini [...]
Frees all data structures allocated by previous calls to fontconfig functions. Fontconfig returns to an uninitialized state, requiring a new call to one of the FcInit functions before any other fontconfig function may be called.
However, the docs do not say why I might want to call it. It will free some memory, but I cannot imagine fontconfig will gobble up vast amounts of memory. At any rate, unless I can make sure I'll never call fontconfig again, I can only call FcFini at the end of my program, where releasing memory is pointless. So why bother?
Incidentally, I noticed that the cairo rendering library, which uses fontconfig, only calls FcFini
in its test code, but never in the production code. So it seems the cairo authors also don't see the point of calling it... or are they wrong?
A typical reason is getting a valid output from valgrind or purify. If you have leaks at exit, you might want to reduce those in debug or test builds.