13

I managed to get a capacity exceeded message by adding a bit too many named coordinates to a number of tikzpictures and so started to test and now wonder if it is possible to release unneeded space in the string pool.

As an example: The following document creates quite a number of (local!) definitions and dies with pdflatex (TL2016) with the message

! TeX capacity exceeded, sorry [pool size=6136953].
\__prg_map_2:w ...sname test#1_17156_tl\endcsname 

It dies with lualatex with the message

! TeX capacity exceeded, sorry [number of strings=495118].
<recently read> \__int_eval_end: 

\documentclass{article}
\usepackage{expl3}

\begin{document}
bb
\ExplSyntaxOn

\int_step_inline:nnnn { 1 } { 1 } {20000}
 {
  \group_begin:
  \int_step_inline:nnnn { 1 } { 1 } {25}
  {
   \expandafter\def\csname test##1_#1_tl\endcsname{}
  }
  \group_end:
 }
\ExplSyntaxOff

\end{document}

Would it be possible to release the space used by the local definitions and decrease the number of strings after the end of the group? Or is there a way to create really local definitions?

Attention I'm not asking how to enlarge the pool size. I know how to do it.

9
  • 2
    space can be recaptured in the string pool, as i understand it, only if it was the most recent space assigned. that is one of the reasons why it can "run out" by opening too many files -- something almost always touches the pool when a file is read in, so the file name is "frozen" there. let me see if i can find a reference. Commented Jun 28, 2016 at 12:24
  • Ah, the \csname-in-a-group issue :-) Not sure there is a solution, but it is an 'interesting' one isn't it!
    – Joseph Wright
    Commented Jun 28, 2016 at 12:27
  • 1
    the section in tex.web regarding the string pool contains the sentence "To destroy the most recently made string, we say |flush_string|." there is no other "cleaning" function in the original program. don't know if the lua gang figured out how to do it. (is this an answer?) Commented Jun 28, 2016 at 12:45
  • 1
    line number in tex.web (Version 3.14159265, January 2014): 1201. Commented Jun 28, 2016 at 14:29
  • 1
    @DavidCarlisle What I meant, is that "number of strings" is perhaps a different register than pool size ("characters in strings"). Looking at the manual the status library has beside pool_size a max_strings and str_ptr field. Commented Sep 4, 2016 at 9:56

1 Answer 1

3

Would it be possible to release the space used by the local definitions and decrease the number of strings after the end of the group?

Answers are already given in the comments :-).

Answer for standard TeX.web: NO, created string entries and the characters for the string in the string pool are never released after they are created. There is only a small optimization possible for the last created string. Thus either the "maximum number of strings" or the "string pool" will overflow depending on the constants in the TeX.web change file.

Answer for LuaTeX (Status January 2023): NO, because in principle the LuaTeX code uses the same code as in TeX.web. The constants for the pool size and the maximum number of strings are enlarged to huge constants, but they are still constants and strings and the reserved characters for strings are never released. (See "source/texk/web2c/luatexdir/tex/stringpool.h" for the LuaTeX constants and "source/texk/web2c/luatexdir/tex/stringpool.c" for the code with the description in the comment.)

Or is there a way to create really local definitions?

No, if you create local csnames and if these csnames have totally different "names". In all these cases they will allocate a new string and allocate characters for the string in the string pool.

You can try to minimize the impact by using always the same set of csnames in all local groups.

Or you implement a different way how to reference your "named coordinates" to a reasonable number.

(Or someone re-implements the TeX string pool functions in a completely different way in the LuaTeX code to allocate and release LuaTeX internal strings in a more dynamic way. This will be a bigger effort with more side effects to the table of equivalents etc. And if some user will assign global defined "named coordinates" you will have the same problem again, because you can't release the strings for the globally defined csnames when the local group closes.)

1
  • 1
    nice summary of the comments ;-) Commented Jan 8, 2023 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .