How to increase memory in LaTeX compiler for handling larges figures in MATLAB2TikZ? For MAC: In the “texmf.cnf” file in: Macintosh HD/Library/TeX/Root/ add the following lines at the end: main_memory = 10000000 save_size = 10000000 extra_mem_top = 150000000 extra_mem_bot = 150000000 Then open a terminal window and type: sudo fmtutil-sys --all References: http://tex.stackexchange.com/questions/7953/how-to-expand-texs-main-memory-size-pgfplots-memory-overload http://tex.stackexchange.com/questions/67014/latex-gives-me-the-error-ouch-my-internal-constants-have-been-clobbered http://www.nburles.co.uk/latex/increasing-the-main-memory-of-latex