Stream: bugs

Topic: Multiline top-level string literal leaking memory


view this post on Zulip Matthieu Pizenberg (Dec 08 2025 at 18:10):

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
}

view this post on Zulip Matthieu Pizenberg (Dec 08 2025 at 18:12):

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?

view this post on Zulip Matthieu Pizenberg (Dec 08 2025 at 18:18):

I opened an issue about it: https://github.com/roc-lang/roc/issues/8592

view this post on Zulip Luke Boswell (Dec 09 2025 at 07:23):

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

view this post on Zulip Luke Boswell (Dec 09 2025 at 07:25):

It was caused by one or more of these issues - a double-decref in list_concat and also a memory leak from findCapturedValue

view this post on Zulip Matthieu Pizenberg (Dec 09 2025 at 15:49):

image.png


Last updated: Dec 21 2025 at 12:15 UTC