9

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?

Martin Scharrer
  • 262,582
  • 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
  • That's an enormous TikZ file! We're unlikely to have a solution other than 'do not use such a big input file', so I'm closing as too localized. – Joseph Wright Nov 21 '12 at 08:37
  • I'm having this problem too using a relatively small file made from knitr.... – Philip Feb 07 '13 at 04:23
  • @tohecz: Why is PSTricks required to precompile the images? Marvis could just use e.g. standalone to precompile the tikzpictures and include them into the main document as images. With an automatic generated document this extra steps should not really be an issue. – Martin Scharrer Feb 07 '13 at 07:20
  • 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 07 '13 at 07: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 07 '13 at 08:23
  • @MartinScharrer The texfile has only the tikz picture. I export the figure using the TikZ library external. The problem is that the tikz commands to create the figure (i.e. inside \begin{tikzpicture} \end{tikzpicture}) is nearly 10,000 lines. –  Feb 07 '13 at 08:32
  • @JosephWright fair point; that turned out to be exactly the cause of my trouble. Martin also fair point; for me though, that's why this question was useful--led me to a solution of the problem given the only info I had. (Sometimes people with an error don't know what's causing the error, so a question about resolving an error according to what's implied by the error msg is a launching off point.) Anyway, for anyone who gets this error using knitr, the solution for me, per JosephWright's advice, was to check carefully that I wasn't asking R to print anything absurdly long. Thx! :) – Philip Feb 08 '13 at 05:54

0 Answers0