I recently made an adaptation of
pgfpages which allows one to gather in several typeset pages and then lay them out in some layout over several physical pages (the original
pgfpages only allows one physical page). Thinking about other possible extensions, I started wondering just how many typeset pages TeX can hold in its memory at a time. In the comments to a Village's self-answer on How to sort the order of pages so that they can be printed in a folded book?, there's a hint that TeX can hold a large number of pages before actually shipping any out. And when I think about what little I know about a PDF document, it would appear that TeX has to process the entire document before it can actually write a single page to the output (I believe that the PDF has to say at the start how long it is).
PGFPages works by storing the pages in boxes, so this might be a bit different to how TeX stores actual pages before writing them to the file. If this is different, I'm more interested in how many boxes TeX can hold at a single time.
I realise that this also might be system-dependent, in which case I'd like to get some idea of how it is dependent, and what the "stock TeX" can do as I'd rather not modify the memory capabilities just for this juggling ability.
So how many boxes can TeX juggle before it runs the risk of dropping them?