增加記憶力

增加記憶力

我正在處理一個大約 4000 頁的文檔,每頁至少有 30 個圖形。有很多字體切換和不同字元的不同顏色。我能夠限制輸出的頁面,這使我能夠成功編譯。我正在使用 MikTex 64 位,但在嘗試通過 texLive 時注意到相同的問題。

但是,當我嘗試將頁數增加到超過一定數量時,LuaLaTex 會退出:

! TeX capacity exceeded, sorry [number of strings=493869].
<argument> ...ter {\reserved@b Pianos/256px/F/Piano_482.png} 
                                                  \ifeof \@inputcheck \else ...

l.33572 ...m]{{Pianos/256px/F/Piano_482.png}}F ♮3}
                                                   & \textcolor{F-Lt}{F} &  ...

 47374 words of node memory still in use:
   972 hlist, 276 vlist, 615 rule, 1 adjust, 7 disc, 276 local_par, 7 dir, 4 ma
th, 1376 glue, 30 kern, 388 penalty, 96 unset, 596 glyph, 16 align_record, 3318
 attribute, 142 glue_spec, 1660 attribute_list, 14 temp, 1 align_stack, 4 if_st
ack, 1 pdf_dest, 3 pdf_action, 412 pdf_colorstack, 26 pdf_setmatrix, 26 pdf_sav
e, 26 pdf_restore nodes
   avail lists: 1:1,2:32136,3:1080,4:450,5:513,6:468,7:9915,8:39,9:4238,10:45,1
1:507
!  ==> Fatal error occurred, no output PDF file produced!
SyncTeX written on document.synctex.gz.
Transcript written on document.log.

我無法真正發布 MWE,因為我認為故障主要來自於包含數千次圖像。我正在嘗試將命令列選項傳遞到lualatexwith -extra-mem-top=50000000

我也嘗試編輯我的 textmf 文件,但它似乎並沒有真正改變那個神奇的數字(493869)字串數。我還運行 64 位元版本的二進位文件,因為我讀到它可以幫助記憶體分配,但實際上並沒有改變任何東西。

答案1

LuaTeX 對主記憶體使用動態記憶體分配,因此 texmf.cnf即使您為 luatex 而不是 pdftex 設定 if,您所使用的設定也不會產生任何影響。

然而它仍然繼承了經典 tex 的一些固定數組用法,包括字串的數量。

這會產生您所說的錯誤(請注意,這是一個無限循環,因此它依靠在錯誤條件下終止。

\documentclass{article}

\begin{document}

\loop
\iftrue
\advance\count0 1
\expandafter\def\csname zzz\the\count0\endcsname{}
\repeat
\end{document}

這會產生

LaTeX2e <2019-10-01> patch level 3

luaotfload | main : initialization completed in 2.242 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (./cc372.aux)
! TeX capacity exceeded, sorry [number of strings=493861].

您可以透過以下呼叫來增加字串數量(或透過編輯 texmf.cnf)

$ max_strings=1000000 lualatex cc372
This is LuaTeX, Version 1.10.0 (TeX Live 2019) 
 restricted system commands enabled.
(./cc372.tex
LaTeX2e <2019-10-01> patch level 3

luaotfload | main : initialization completed in 2.141 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (./cc372.aux)
! TeX capacity exceeded, sorry [hash size=665536].
<recently read> \endcsname 

現在您會看到它並沒有用完字串,而是溢出了哈希表,可以類似地增加哈希表。您需要迭代您的真實文件以增加所需的內容。

在這裡,如果我將哈希表的大小增加得足夠多,則需要幾秒鐘的時間才能運行,但最終會再次耗盡字串:

$ max_strings=1000000 hash_extra=1000000 lualatex cc372
This is LuaTeX, Version 1.10.0 (TeX Live 2019) 
 restricted system commands enabled.
(./cc372.tex
LaTeX2e <2019-10-01> patch level 3

luaotfload | main : initialization completed in 2.187 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (./cc372.aux)
! TeX capacity exceeded, sorry [number of strings=993861].

答案2

編輯lualatex.ini以使用大衛·卡萊爾建議的值,然後重建格式就成功了。我很高興。

我的lualatex.ini文件:

main_memory=12000000
pool_size=4250000
max_strings=8000000
hash_extra=1000000

為了找到路徑,我打開了 MikTeX 控制台,然後轉到「設定」>「目錄」>(然後是標記為「配置」的那個)。打開該資料夾,然後./miktex/config/lualatex.ini從那裡開始。謝謝!

相關內容