I wrote a C++ code, which will create a LaTeX file with Tikz commands. The tex file the code creates is pretty long i.e. around 43,000 lines. However, when I try to compile it gives me the following error.

! TeX capacity exceeded, sorry [main memory size=3000000].

Is there anyway I can circumvent this error?

closed as too localized by Joseph Wright Nov 21 '12 at 8:36

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You could try luatex which does dynamic memory allocation but that means it may eat all the memory on your machine rather than giving up, it depends how much memory the document really needs – David Carlisle Oct 19 '12 at 22:06
  • With such a complicated TikZ code, you'll very likely get some other error after you solve this (for example Dimension too large). I recommend switching to pstricks and precompiling the images, if this is possible. – yo' Oct 19 '12 at 23:48
  • 2
    @Philip: No I don't think you also have this problem. You only get the same error message. This error also appears if e.g. an (incorrect) recursive macro builds up the input memory (\def\recmacro{\recmacro Text} would add 'Text' to the input buffer until its full). This append to me with the apacite package recently. Here allocating more memory doesn't help. – Martin Scharrer Feb 7 '13 at 7:24
  • 2
  • 2
    @Philip The problem with saying 'I have the same issue' here is that the question is pretty vague: we have no solid example to see if the issue is the length of the file or what it's trying to do. TeX will happily process huge documents, but will run into trouble if you try to do too many (usually graphical) operations on one page. – Joseph Wright Feb 7 '13 at 8:23