[XeTeX] xetex memory usage

Jonathan Kew jonathan at jfkew.plus.com
Tue Dec 16 22:51:47 CET 2008

On 16 Dec 2008, at 19:53, basketboy at bk.ru wrote:

> Hello,
> I'm using MiKTeX 2.7 and xetex(xelatex) integrated in it. OS:  
> Windows XP
> SP3.
> My question is about memory usage of xetex. I've noticed that when I
> compile tex document, though this:
> \documentclass{article}
> \usepackage{fontspec}
> \setmainfont{Arial}
> \begin{document}
> The quick brown fox jumps over the lazy dog.
> \textbf{The quick brown fox jumps over the lazy dog.}
> \emph{The quick brown fox jumps over the lazy dog.}
> \end{document}
> I see that it uses at least 130MB of RAM to generate pdf. So if for
> example I'm going to use xetex to generate pdf reports via webpage it
> can cause memory overusage. For example if 10 people start to generate
> pdfs simultaneously then 1300Mb of RAM will be used and it can cause  
> the
> problems. We run into this problem already (with much more complex tex
> documents) and server with 512 MB of RAM and it was overloaded.
> So my questions are the following:
> 1. Is this problem related with xetex or maybe fonts loading into
> memory? If it is not related to xetex then sorry, I'll try to find
> answer from MiKTeX users.

The RAM footprint is much larger than standard 8-bit TeX because many  
internal tables have been expanded to cover the full Unicode range of  
characters -- approximately one million, as compared to 256  
characters. Using over 100MB is not generally a problem on modern  
hardware; much of this memory is not actively used in a typical run,  
and so virtual memory systems need not even keep it in real RAM, but  
it does get allocated at startup.

> 2. Is it possilbe to reduce RAM consumption in this case?

Not with the existing program. Many of the internal arrays could be  
made much smaller by using a smarter "sparse array" implementation  
instead of simple flat arrays. This has not been a priority for me, as  
users do not normally need to run large numbers of xetex processes in  
parallel, but if someone wants to provide such a patch it would be  

Actually, you could reduce the RAM footprint quite a bit by reducing  
various parameters in texmf.cnf (for TeX Live; I don't know if MikTeX  
uses a similar configuration file), as the default settings (at least  
with TL) are extremely generous, and most documents can be processed  
within much smaller limits.


More information about the XeTeX mailing list