sine-fdn/polytune#176 shows that just the compilation can already require a significant amount of peak memory for large circuits.
I think some of the memory is required for optimizations done during CircuitBuilder::build(). If that is the case, we could have an option of compiling without optimizations to reduce memory consumption.