If I save the *compilation* buffer and restart emacs, memory usage goes up modestly when I load the file (52MB; it is automatically fontified by emacs when I load it):
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
peter 19037 0.6 0.7 441776 115476 ? Ssl 11:59 2:49 emacs --daemon
peter 19037 0.6 1.0 495832 169776 ? Ssl 11:59 2:50 emacs --daemon
and memory usage returns to about the previous value when I kill the buffer (I don't need to run 'garbage-collect).
So, the problems seems to be somewhere in the "compile" command:
(a) it uses a *lot* more memory than needed to display the result
(b) it doesn't free that memory when compilation ends or when the compilation buffer is killed
My "compilation" is actually compile plus 8200 tests, speeding them up by using GNU-parallel.