On 10/29/2024 6:13 AM, user202729--- via luatex wrote:
I notice that the `run_put_next` function inserts the token list using
begin_token_list(h,0);
however, this has the problem that in `end_token_list`, the token list is not
freed when the type is `0` (i.e. `parameter`).
I think the `0` should be changed to e.g. `inserted` (4), so that it is
correctly freed.
indeed it should be an inserted list (that's what we have in luametatex
and no mem issue)
For a test case, consider the following program.
```
lualatex '\directlua{i=1; t=token.get_next()}~\def~#1A{\directlua{i=i+1;if
i&1023==0 then print(i) end;for i=1,1000 do token.put_next(t); end}A}~A'
</dev/null
```
Before the change, the memory usage grows steadily. After the change, the
memory usage remains constant.
Please take a look. Thank you.
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------