Release space in the string pool

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].

\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.

• 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. – barbara beeton Jun 28 '16 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 Jun 28 '16 at 12:27
• @JosephWright: It is not only \csname (in case you mean commands build with \csname), \def\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX{} fills the pool too, but it much more difficult to overflow it with "normal definitions" than by using \csname and loops. – Ulrike Fischer Jun 28 '16 at 12:35
• 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?) – barbara beeton Jun 28 '16 at 12:45
• line number in tex.web (Version 3.14159265, January 2014): 1201. – barbara beeton Jun 28 '16 at 14:29