In my experience most memory is used when linking, not when compiling,
but I guess it can get pretty bad when compiling huge C++ codes with
The thing is, you probably can't throw away much in each intermediate step,
because you do need all that info, but you can easily throw away data
generated by a whole intermediate step and keep only the intermediate
results. So the main way to limit memory usage is by limiting the working
set. GC doesn't help with that.