Program compiled with -O2 exhibits much worse performance
A user on reddit reports that compiling the program with
-O2 makes his program use a lot more memory.
It runs in constant memory without
-O2 and leaks memory with `-O2. It seems worth investigating as
the example is quite small (< 1000 lines) and self-contained.