My day01.roc AoC solution works but leaks memory. I minimized it to the following example. It seems the memory leak only manifests if the string literal is top-level (not in main) and if multi-line string literal (\\ syntax).
# Only multi-line syntax leaks memory
# Single-line string literal does not leak memory: "Very long single-line string does not leak memory \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLLLLLLLLLLLL"
# Multi-line string literal defined in main does not leak memory
multi_line_constant =
\\0
\\1
\\2
\\3
\\4
\\5
\\6
\\7
\\8
\\9
\\a
\\b
\\c
main! = || {
_result = multi_line_constant
}
Is it possible that the concatenation of the parts making the top-level string constant call some functions that allocate memory, and we don’t de-allocate it because it’s assumed top-level constants are from some arena that doesn’t need de-allocating?
I opened an issue about it: https://github.com/roc-lang/roc/issues/8592
Took me a few hours to get to the bottom of this one, it came up as an issue for me in CI with more test coverage while trying to merge the roc build PR. Anyway should be fixed in https://github.com/roc-lang/roc/pull/8548
It was caused by one or more of these issues - a double-decref in list_concat and also a memory leak from findCapturedValue
Last updated: Dec 21 2025 at 12:15 UTC