[metapost] memory leak in decimal/binary?
Martin Budaj
m.budaj at gmail.com
Fri Feb 3 21:00:46 CET 2023
Hi,
I've encountered an enormous memory usage (and long run times) of mpost
when running in the decimal/binary mode and processing a lot of stored
paths.
It can be demonstrated on the following cycle (the exact path definition
doesn't matter but should be long enough to make the issue obvious):
path p;
for i:= 0 upto 4000:
p:=(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..
(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40);
endfor;
end.
It uses gigabytes of memory in the decimal mode (and somewhat less in
binary), so something is probably going wrong:
Command being timed: "mpost --numbersystem=scaled test.mp"
User time (seconds): 1.42
Maximum resident set size (kbytes): 40768
Command being timed: "mpost --numbersystem=double test.mp"
User time (seconds): 0.61
Maximum resident set size (kbytes): 41728
Command being timed: "mpost --numbersystem=decimal test.mp"
User time (seconds): 498.56
Maximum resident set size (kbytes): 37244480
Command being timed: "mpost --numbersystem=binary test.mp"
User time (seconds): 187.32
Maximum resident set size (kbytes): 10906672
After some experiments with the number of loop repetitions it seems that
the memory usage (and the run time) increases linearly with the number of
iterations.
MP version: This is MetaPost, version 2.02 (TeX Live 2022/Debian) (kpathsea
version 6.3.4)
Best wishes
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/metapost/attachments/20230203/cd4e04fd/attachment.html>
More information about the metapost
mailing list.