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?
texmf.cnfyou can blow up the size of the TeX process to several GB, so that you need at 64bit system to even handle it. Ridiculous amounts of stuff can be held in main memory then. I'm getting a memory usage of253480166 words of memory out of 254931841. – Stephan Lehmke Jul 26 '12 at 12:58[1], [2]messages on the console after each page is shipped. Secondly, if page 10 of your source file has a syntax error, TeX still generates 9 pages of output. Even in the ConTeXt example that you had linked to, ConText ships out pages as they are done and does the rearranging at the end (I don't know the algo, I am just guessing from the console output). – Aditya Jul 26 '12 at 18:39streamlength, but that appears to be a per-page thing rather than the whole document. Thanks for clarifying. – Andrew Stacey Jul 26 '12 at 20:34